{-# 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.HistogramBinOptions
-- 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.HistogramBinOptions 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
import Amazonka.QuickSight.Types.BinCountOptions
import Amazonka.QuickSight.Types.BinWidthOptions
import Amazonka.QuickSight.Types.HistogramBinType

-- | The options that determine the presentation of histogram bins.
--
-- /See:/ 'newHistogramBinOptions' smart constructor.
data HistogramBinOptions = HistogramBinOptions'
  { -- | The options that determine the bin count of a histogram.
    HistogramBinOptions -> Maybe BinCountOptions
binCount :: Prelude.Maybe BinCountOptions,
    -- | The options that determine the bin width of a histogram.
    HistogramBinOptions -> Maybe BinWidthOptions
binWidth :: Prelude.Maybe BinWidthOptions,
    -- | The options that determine the selected bin type.
    HistogramBinOptions -> Maybe HistogramBinType
selectedBinType :: Prelude.Maybe HistogramBinType,
    -- | The options that determine the bin start value.
    HistogramBinOptions -> Maybe Double
startValue :: Prelude.Maybe Prelude.Double
  }
  deriving (HistogramBinOptions -> HistogramBinOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HistogramBinOptions -> HistogramBinOptions -> Bool
$c/= :: HistogramBinOptions -> HistogramBinOptions -> Bool
== :: HistogramBinOptions -> HistogramBinOptions -> Bool
$c== :: HistogramBinOptions -> HistogramBinOptions -> Bool
Prelude.Eq, ReadPrec [HistogramBinOptions]
ReadPrec HistogramBinOptions
Int -> ReadS HistogramBinOptions
ReadS [HistogramBinOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HistogramBinOptions]
$creadListPrec :: ReadPrec [HistogramBinOptions]
readPrec :: ReadPrec HistogramBinOptions
$creadPrec :: ReadPrec HistogramBinOptions
readList :: ReadS [HistogramBinOptions]
$creadList :: ReadS [HistogramBinOptions]
readsPrec :: Int -> ReadS HistogramBinOptions
$creadsPrec :: Int -> ReadS HistogramBinOptions
Prelude.Read, Int -> HistogramBinOptions -> ShowS
[HistogramBinOptions] -> ShowS
HistogramBinOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HistogramBinOptions] -> ShowS
$cshowList :: [HistogramBinOptions] -> ShowS
show :: HistogramBinOptions -> String
$cshow :: HistogramBinOptions -> String
showsPrec :: Int -> HistogramBinOptions -> ShowS
$cshowsPrec :: Int -> HistogramBinOptions -> ShowS
Prelude.Show, forall x. Rep HistogramBinOptions x -> HistogramBinOptions
forall x. HistogramBinOptions -> Rep HistogramBinOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HistogramBinOptions x -> HistogramBinOptions
$cfrom :: forall x. HistogramBinOptions -> Rep HistogramBinOptions x
Prelude.Generic)

-- |
-- Create a value of 'HistogramBinOptions' 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:
--
-- 'binCount', 'histogramBinOptions_binCount' - The options that determine the bin count of a histogram.
--
-- 'binWidth', 'histogramBinOptions_binWidth' - The options that determine the bin width of a histogram.
--
-- 'selectedBinType', 'histogramBinOptions_selectedBinType' - The options that determine the selected bin type.
--
-- 'startValue', 'histogramBinOptions_startValue' - The options that determine the bin start value.
newHistogramBinOptions ::
  HistogramBinOptions
newHistogramBinOptions :: HistogramBinOptions
newHistogramBinOptions =
  HistogramBinOptions'
    { $sel:binCount:HistogramBinOptions' :: Maybe BinCountOptions
binCount = forall a. Maybe a
Prelude.Nothing,
      $sel:binWidth:HistogramBinOptions' :: Maybe BinWidthOptions
binWidth = forall a. Maybe a
Prelude.Nothing,
      $sel:selectedBinType:HistogramBinOptions' :: Maybe HistogramBinType
selectedBinType = forall a. Maybe a
Prelude.Nothing,
      $sel:startValue:HistogramBinOptions' :: Maybe Double
startValue = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The options that determine the bin width of a histogram.
histogramBinOptions_binWidth :: Lens.Lens' HistogramBinOptions (Prelude.Maybe BinWidthOptions)
histogramBinOptions_binWidth :: Lens' HistogramBinOptions (Maybe BinWidthOptions)
histogramBinOptions_binWidth = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistogramBinOptions' {Maybe BinWidthOptions
binWidth :: Maybe BinWidthOptions
$sel:binWidth:HistogramBinOptions' :: HistogramBinOptions -> Maybe BinWidthOptions
binWidth} -> Maybe BinWidthOptions
binWidth) (\s :: HistogramBinOptions
s@HistogramBinOptions' {} Maybe BinWidthOptions
a -> HistogramBinOptions
s {$sel:binWidth:HistogramBinOptions' :: Maybe BinWidthOptions
binWidth = Maybe BinWidthOptions
a} :: HistogramBinOptions)

-- | The options that determine the selected bin type.
histogramBinOptions_selectedBinType :: Lens.Lens' HistogramBinOptions (Prelude.Maybe HistogramBinType)
histogramBinOptions_selectedBinType :: Lens' HistogramBinOptions (Maybe HistogramBinType)
histogramBinOptions_selectedBinType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistogramBinOptions' {Maybe HistogramBinType
selectedBinType :: Maybe HistogramBinType
$sel:selectedBinType:HistogramBinOptions' :: HistogramBinOptions -> Maybe HistogramBinType
selectedBinType} -> Maybe HistogramBinType
selectedBinType) (\s :: HistogramBinOptions
s@HistogramBinOptions' {} Maybe HistogramBinType
a -> HistogramBinOptions
s {$sel:selectedBinType:HistogramBinOptions' :: Maybe HistogramBinType
selectedBinType = Maybe HistogramBinType
a} :: HistogramBinOptions)

-- | The options that determine the bin start value.
histogramBinOptions_startValue :: Lens.Lens' HistogramBinOptions (Prelude.Maybe Prelude.Double)
histogramBinOptions_startValue :: Lens' HistogramBinOptions (Maybe Double)
histogramBinOptions_startValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistogramBinOptions' {Maybe Double
startValue :: Maybe Double
$sel:startValue:HistogramBinOptions' :: HistogramBinOptions -> Maybe Double
startValue} -> Maybe Double
startValue) (\s :: HistogramBinOptions
s@HistogramBinOptions' {} Maybe Double
a -> HistogramBinOptions
s {$sel:startValue:HistogramBinOptions' :: Maybe Double
startValue = Maybe Double
a} :: HistogramBinOptions)

instance Data.FromJSON HistogramBinOptions where
  parseJSON :: Value -> Parser HistogramBinOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HistogramBinOptions"
      ( \Object
x ->
          Maybe BinCountOptions
-> Maybe BinWidthOptions
-> Maybe HistogramBinType
-> Maybe Double
-> HistogramBinOptions
HistogramBinOptions'
            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
"BinCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"BinWidth")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SelectedBinType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StartValue")
      )

instance Prelude.Hashable HistogramBinOptions where
  hashWithSalt :: Int -> HistogramBinOptions -> Int
hashWithSalt Int
_salt HistogramBinOptions' {Maybe Double
Maybe BinCountOptions
Maybe BinWidthOptions
Maybe HistogramBinType
startValue :: Maybe Double
selectedBinType :: Maybe HistogramBinType
binWidth :: Maybe BinWidthOptions
binCount :: Maybe BinCountOptions
$sel:startValue:HistogramBinOptions' :: HistogramBinOptions -> Maybe Double
$sel:selectedBinType:HistogramBinOptions' :: HistogramBinOptions -> Maybe HistogramBinType
$sel:binWidth:HistogramBinOptions' :: HistogramBinOptions -> Maybe BinWidthOptions
$sel:binCount:HistogramBinOptions' :: HistogramBinOptions -> Maybe BinCountOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BinCountOptions
binCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BinWidthOptions
binWidth
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HistogramBinType
selectedBinType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
startValue

instance Prelude.NFData HistogramBinOptions where
  rnf :: HistogramBinOptions -> ()
rnf HistogramBinOptions' {Maybe Double
Maybe BinCountOptions
Maybe BinWidthOptions
Maybe HistogramBinType
startValue :: Maybe Double
selectedBinType :: Maybe HistogramBinType
binWidth :: Maybe BinWidthOptions
binCount :: Maybe BinCountOptions
$sel:startValue:HistogramBinOptions' :: HistogramBinOptions -> Maybe Double
$sel:selectedBinType:HistogramBinOptions' :: HistogramBinOptions -> Maybe HistogramBinType
$sel:binWidth:HistogramBinOptions' :: HistogramBinOptions -> Maybe BinWidthOptions
$sel:binCount:HistogramBinOptions' :: HistogramBinOptions -> Maybe BinCountOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BinCountOptions
binCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BinWidthOptions
binWidth
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HistogramBinType
selectedBinType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
startValue

instance Data.ToJSON HistogramBinOptions where
  toJSON :: HistogramBinOptions -> Value
toJSON HistogramBinOptions' {Maybe Double
Maybe BinCountOptions
Maybe BinWidthOptions
Maybe HistogramBinType
startValue :: Maybe Double
selectedBinType :: Maybe HistogramBinType
binWidth :: Maybe BinWidthOptions
binCount :: Maybe BinCountOptions
$sel:startValue:HistogramBinOptions' :: HistogramBinOptions -> Maybe Double
$sel:selectedBinType:HistogramBinOptions' :: HistogramBinOptions -> Maybe HistogramBinType
$sel:binWidth:HistogramBinOptions' :: HistogramBinOptions -> Maybe BinWidthOptions
$sel:binCount:HistogramBinOptions' :: HistogramBinOptions -> Maybe BinCountOptions
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BinCount" 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 BinCountOptions
binCount,
            (Key
"BinWidth" 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 BinWidthOptions
binWidth,
            (Key
"SelectedBinType" 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 HistogramBinType
selectedBinType,
            (Key
"StartValue" 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 Double
startValue
          ]
      )