{-# 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.GaugeChartFieldWells
-- 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.GaugeChartFieldWells 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.MeasureField

-- | The field well configuration of a @GaugeChartVisual@.
--
-- /See:/ 'newGaugeChartFieldWells' smart constructor.
data GaugeChartFieldWells = GaugeChartFieldWells'
  { -- | The target value field wells of a @GaugeChartVisual@.
    GaugeChartFieldWells -> Maybe [MeasureField]
targetValues :: Prelude.Maybe [MeasureField],
    -- | The value field wells of a @GaugeChartVisual@.
    GaugeChartFieldWells -> Maybe [MeasureField]
values :: Prelude.Maybe [MeasureField]
  }
  deriving (GaugeChartFieldWells -> GaugeChartFieldWells -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GaugeChartFieldWells -> GaugeChartFieldWells -> Bool
$c/= :: GaugeChartFieldWells -> GaugeChartFieldWells -> Bool
== :: GaugeChartFieldWells -> GaugeChartFieldWells -> Bool
$c== :: GaugeChartFieldWells -> GaugeChartFieldWells -> Bool
Prelude.Eq, Int -> GaugeChartFieldWells -> ShowS
[GaugeChartFieldWells] -> ShowS
GaugeChartFieldWells -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GaugeChartFieldWells] -> ShowS
$cshowList :: [GaugeChartFieldWells] -> ShowS
show :: GaugeChartFieldWells -> String
$cshow :: GaugeChartFieldWells -> String
showsPrec :: Int -> GaugeChartFieldWells -> ShowS
$cshowsPrec :: Int -> GaugeChartFieldWells -> ShowS
Prelude.Show, forall x. Rep GaugeChartFieldWells x -> GaugeChartFieldWells
forall x. GaugeChartFieldWells -> Rep GaugeChartFieldWells x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GaugeChartFieldWells x -> GaugeChartFieldWells
$cfrom :: forall x. GaugeChartFieldWells -> Rep GaugeChartFieldWells x
Prelude.Generic)

-- |
-- Create a value of 'GaugeChartFieldWells' 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:
--
-- 'targetValues', 'gaugeChartFieldWells_targetValues' - The target value field wells of a @GaugeChartVisual@.
--
-- 'values', 'gaugeChartFieldWells_values' - The value field wells of a @GaugeChartVisual@.
newGaugeChartFieldWells ::
  GaugeChartFieldWells
newGaugeChartFieldWells :: GaugeChartFieldWells
newGaugeChartFieldWells =
  GaugeChartFieldWells'
    { $sel:targetValues:GaugeChartFieldWells' :: Maybe [MeasureField]
targetValues =
        forall a. Maybe a
Prelude.Nothing,
      $sel:values:GaugeChartFieldWells' :: Maybe [MeasureField]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The target value field wells of a @GaugeChartVisual@.
gaugeChartFieldWells_targetValues :: Lens.Lens' GaugeChartFieldWells (Prelude.Maybe [MeasureField])
gaugeChartFieldWells_targetValues :: Lens' GaugeChartFieldWells (Maybe [MeasureField])
gaugeChartFieldWells_targetValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GaugeChartFieldWells' {Maybe [MeasureField]
targetValues :: Maybe [MeasureField]
$sel:targetValues:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
targetValues} -> Maybe [MeasureField]
targetValues) (\s :: GaugeChartFieldWells
s@GaugeChartFieldWells' {} Maybe [MeasureField]
a -> GaugeChartFieldWells
s {$sel:targetValues:GaugeChartFieldWells' :: Maybe [MeasureField]
targetValues = Maybe [MeasureField]
a} :: GaugeChartFieldWells) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The value field wells of a @GaugeChartVisual@.
gaugeChartFieldWells_values :: Lens.Lens' GaugeChartFieldWells (Prelude.Maybe [MeasureField])
gaugeChartFieldWells_values :: Lens' GaugeChartFieldWells (Maybe [MeasureField])
gaugeChartFieldWells_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GaugeChartFieldWells' {Maybe [MeasureField]
values :: Maybe [MeasureField]
$sel:values:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
values} -> Maybe [MeasureField]
values) (\s :: GaugeChartFieldWells
s@GaugeChartFieldWells' {} Maybe [MeasureField]
a -> GaugeChartFieldWells
s {$sel:values:GaugeChartFieldWells' :: Maybe [MeasureField]
values = Maybe [MeasureField]
a} :: GaugeChartFieldWells) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON GaugeChartFieldWells where
  parseJSON :: Value -> Parser GaugeChartFieldWells
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GaugeChartFieldWells"
      ( \Object
x ->
          Maybe [MeasureField]
-> Maybe [MeasureField] -> GaugeChartFieldWells
GaugeChartFieldWells'
            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
"TargetValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable GaugeChartFieldWells where
  hashWithSalt :: Int -> GaugeChartFieldWells -> Int
hashWithSalt Int
_salt GaugeChartFieldWells' {Maybe [MeasureField]
values :: Maybe [MeasureField]
targetValues :: Maybe [MeasureField]
$sel:values:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
$sel:targetValues:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MeasureField]
targetValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MeasureField]
values

instance Prelude.NFData GaugeChartFieldWells where
  rnf :: GaugeChartFieldWells -> ()
rnf GaugeChartFieldWells' {Maybe [MeasureField]
values :: Maybe [MeasureField]
targetValues :: Maybe [MeasureField]
$sel:values:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
$sel:targetValues:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [MeasureField]
targetValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MeasureField]
values

instance Data.ToJSON GaugeChartFieldWells where
  toJSON :: GaugeChartFieldWells -> Value
toJSON GaugeChartFieldWells' {Maybe [MeasureField]
values :: Maybe [MeasureField]
targetValues :: Maybe [MeasureField]
$sel:values:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
$sel:targetValues:GaugeChartFieldWells' :: GaugeChartFieldWells -> Maybe [MeasureField]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TargetValues" 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 [MeasureField]
targetValues,
            (Key
"Values" 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 [MeasureField]
values
          ]
      )