{-# 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.DecimalParameter
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.DecimalParameter where

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

-- | A decimal parameter.
--
-- /See:/ 'newDecimalParameter' smart constructor.
data DecimalParameter = DecimalParameter'
  { -- | A display name for the decimal parameter.
    DecimalParameter -> Text
name :: Prelude.Text,
    -- | The values for the decimal parameter.
    DecimalParameter -> [Double]
values :: [Prelude.Double]
  }
  deriving (DecimalParameter -> DecimalParameter -> Bool
(DecimalParameter -> DecimalParameter -> Bool)
-> (DecimalParameter -> DecimalParameter -> Bool)
-> Eq DecimalParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DecimalParameter -> DecimalParameter -> Bool
$c/= :: DecimalParameter -> DecimalParameter -> Bool
== :: DecimalParameter -> DecimalParameter -> Bool
$c== :: DecimalParameter -> DecimalParameter -> Bool
Prelude.Eq, ReadPrec [DecimalParameter]
ReadPrec DecimalParameter
Int -> ReadS DecimalParameter
ReadS [DecimalParameter]
(Int -> ReadS DecimalParameter)
-> ReadS [DecimalParameter]
-> ReadPrec DecimalParameter
-> ReadPrec [DecimalParameter]
-> Read DecimalParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DecimalParameter]
$creadListPrec :: ReadPrec [DecimalParameter]
readPrec :: ReadPrec DecimalParameter
$creadPrec :: ReadPrec DecimalParameter
readList :: ReadS [DecimalParameter]
$creadList :: ReadS [DecimalParameter]
readsPrec :: Int -> ReadS DecimalParameter
$creadsPrec :: Int -> ReadS DecimalParameter
Prelude.Read, Int -> DecimalParameter -> ShowS
[DecimalParameter] -> ShowS
DecimalParameter -> String
(Int -> DecimalParameter -> ShowS)
-> (DecimalParameter -> String)
-> ([DecimalParameter] -> ShowS)
-> Show DecimalParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DecimalParameter] -> ShowS
$cshowList :: [DecimalParameter] -> ShowS
show :: DecimalParameter -> String
$cshow :: DecimalParameter -> String
showsPrec :: Int -> DecimalParameter -> ShowS
$cshowsPrec :: Int -> DecimalParameter -> ShowS
Prelude.Show, (forall x. DecimalParameter -> Rep DecimalParameter x)
-> (forall x. Rep DecimalParameter x -> DecimalParameter)
-> Generic DecimalParameter
forall x. Rep DecimalParameter x -> DecimalParameter
forall x. DecimalParameter -> Rep DecimalParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DecimalParameter x -> DecimalParameter
$cfrom :: forall x. DecimalParameter -> Rep DecimalParameter x
Prelude.Generic)

-- |
-- Create a value of 'DecimalParameter' 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:
--
-- 'name', 'decimalParameter_name' - A display name for the decimal parameter.
--
-- 'values', 'decimalParameter_values' - The values for the decimal parameter.
newDecimalParameter ::
  -- | 'name'
  Prelude.Text ->
  DecimalParameter
newDecimalParameter :: Text -> DecimalParameter
newDecimalParameter Text
pName_ =
  DecimalParameter' :: Text -> [Double] -> DecimalParameter
DecimalParameter'
    { $sel:name:DecimalParameter' :: Text
name = Text
pName_,
      $sel:values:DecimalParameter' :: [Double]
values = [Double]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A display name for the decimal parameter.
decimalParameter_name :: Lens.Lens' DecimalParameter Prelude.Text
decimalParameter_name :: (Text -> f Text) -> DecimalParameter -> f DecimalParameter
decimalParameter_name = (DecimalParameter -> Text)
-> (DecimalParameter -> Text -> DecimalParameter)
-> Lens DecimalParameter DecimalParameter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecimalParameter' {Text
name :: Text
$sel:name:DecimalParameter' :: DecimalParameter -> Text
name} -> Text
name) (\s :: DecimalParameter
s@DecimalParameter' {} Text
a -> DecimalParameter
s {$sel:name:DecimalParameter' :: Text
name = Text
a} :: DecimalParameter)

-- | The values for the decimal parameter.
decimalParameter_values :: Lens.Lens' DecimalParameter [Prelude.Double]
decimalParameter_values :: ([Double] -> f [Double]) -> DecimalParameter -> f DecimalParameter
decimalParameter_values = (DecimalParameter -> [Double])
-> (DecimalParameter -> [Double] -> DecimalParameter)
-> Lens DecimalParameter DecimalParameter [Double] [Double]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DecimalParameter' {[Double]
values :: [Double]
$sel:values:DecimalParameter' :: DecimalParameter -> [Double]
values} -> [Double]
values) (\s :: DecimalParameter
s@DecimalParameter' {} [Double]
a -> DecimalParameter
s {$sel:values:DecimalParameter' :: [Double]
values = [Double]
a} :: DecimalParameter) (([Double] -> f [Double])
 -> DecimalParameter -> f DecimalParameter)
-> (([Double] -> f [Double]) -> [Double] -> f [Double])
-> ([Double] -> f [Double])
-> DecimalParameter
-> f DecimalParameter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Double] -> f [Double]) -> [Double] -> f [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable DecimalParameter

instance Prelude.NFData DecimalParameter

instance Core.ToJSON DecimalParameter where
  toJSON :: DecimalParameter -> Value
toJSON DecimalParameter' {[Double]
Text
values :: [Double]
name :: Text
$sel:values:DecimalParameter' :: DecimalParameter -> [Double]
$sel:name:DecimalParameter' :: DecimalParameter -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Double]
values)
          ]
      )