{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.QuickSight.Types.BinCountOptions
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.BinCountOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The options that determine the bin count of a histogram.
--
-- /See:/ 'newBinCountOptions' smart constructor.
data BinCountOptions = BinCountOptions'
  { -- | The options that determine the bin count value.
    BinCountOptions -> Maybe Natural
value :: Prelude.Maybe Prelude.Natural
  }
  deriving (BinCountOptions -> BinCountOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BinCountOptions -> BinCountOptions -> Bool
$c/= :: BinCountOptions -> BinCountOptions -> Bool
== :: BinCountOptions -> BinCountOptions -> Bool
$c== :: BinCountOptions -> BinCountOptions -> Bool
Prelude.Eq, ReadPrec [BinCountOptions]
ReadPrec BinCountOptions
Int -> ReadS BinCountOptions
ReadS [BinCountOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BinCountOptions]
$creadListPrec :: ReadPrec [BinCountOptions]
readPrec :: ReadPrec BinCountOptions
$creadPrec :: ReadPrec BinCountOptions
readList :: ReadS [BinCountOptions]
$creadList :: ReadS [BinCountOptions]
readsPrec :: Int -> ReadS BinCountOptions
$creadsPrec :: Int -> ReadS BinCountOptions
Prelude.Read, Int -> BinCountOptions -> ShowS
[BinCountOptions] -> ShowS
BinCountOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BinCountOptions] -> ShowS
$cshowList :: [BinCountOptions] -> ShowS
show :: BinCountOptions -> String
$cshow :: BinCountOptions -> String
showsPrec :: Int -> BinCountOptions -> ShowS
$cshowsPrec :: Int -> BinCountOptions -> ShowS
Prelude.Show, forall x. Rep BinCountOptions x -> BinCountOptions
forall x. BinCountOptions -> Rep BinCountOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BinCountOptions x -> BinCountOptions
$cfrom :: forall x. BinCountOptions -> Rep BinCountOptions x
Prelude.Generic)

-- |
-- Create a value of 'BinCountOptions' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'value', 'binCountOptions_value' - The options that determine the bin count value.
newBinCountOptions ::
  BinCountOptions
newBinCountOptions :: BinCountOptions
newBinCountOptions =
  BinCountOptions' {$sel:value:BinCountOptions' :: Maybe Natural
value = forall a. Maybe a
Prelude.Nothing}

-- | The options that determine the bin count value.
binCountOptions_value :: Lens.Lens' BinCountOptions (Prelude.Maybe Prelude.Natural)
binCountOptions_value :: Lens' BinCountOptions (Maybe Natural)
binCountOptions_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BinCountOptions' {Maybe Natural
value :: Maybe Natural
$sel:value:BinCountOptions' :: BinCountOptions -> Maybe Natural
value} -> Maybe Natural
value) (\s :: BinCountOptions
s@BinCountOptions' {} Maybe Natural
a -> BinCountOptions
s {$sel:value:BinCountOptions' :: Maybe Natural
value = Maybe Natural
a} :: BinCountOptions)

instance Data.FromJSON BinCountOptions where
  parseJSON :: Value -> Parser BinCountOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BinCountOptions"
      ( \Object
x ->
          Maybe Natural -> BinCountOptions
BinCountOptions' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Value")
      )

instance Prelude.Hashable BinCountOptions where
  hashWithSalt :: Int -> BinCountOptions -> Int
hashWithSalt Int
_salt BinCountOptions' {Maybe Natural
value :: Maybe Natural
$sel:value:BinCountOptions' :: BinCountOptions -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
value

instance Prelude.NFData BinCountOptions where
  rnf :: BinCountOptions -> ()
rnf BinCountOptions' {Maybe Natural
value :: Maybe Natural
$sel:value:BinCountOptions' :: BinCountOptions -> Maybe Natural
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
value

instance Data.ToJSON BinCountOptions where
  toJSON :: BinCountOptions -> Value
toJSON BinCountOptions' {Maybe Natural
value :: Maybe Natural
$sel:value:BinCountOptions' :: BinCountOptions -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
value]
      )