{-# 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.DataColor
-- 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.DataColor 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

-- | Determines the color that is applied to a particular data value.
--
-- /See:/ 'newDataColor' smart constructor.
data DataColor = DataColor'
  { -- | The color that is applied to the data value.
    DataColor -> Maybe Text
color :: Prelude.Maybe Prelude.Text,
    -- | The data value that the color is applied to.
    DataColor -> Maybe Double
dataValue :: Prelude.Maybe Prelude.Double
  }
  deriving (DataColor -> DataColor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataColor -> DataColor -> Bool
$c/= :: DataColor -> DataColor -> Bool
== :: DataColor -> DataColor -> Bool
$c== :: DataColor -> DataColor -> Bool
Prelude.Eq, ReadPrec [DataColor]
ReadPrec DataColor
Int -> ReadS DataColor
ReadS [DataColor]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataColor]
$creadListPrec :: ReadPrec [DataColor]
readPrec :: ReadPrec DataColor
$creadPrec :: ReadPrec DataColor
readList :: ReadS [DataColor]
$creadList :: ReadS [DataColor]
readsPrec :: Int -> ReadS DataColor
$creadsPrec :: Int -> ReadS DataColor
Prelude.Read, Int -> DataColor -> ShowS
[DataColor] -> ShowS
DataColor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataColor] -> ShowS
$cshowList :: [DataColor] -> ShowS
show :: DataColor -> String
$cshow :: DataColor -> String
showsPrec :: Int -> DataColor -> ShowS
$cshowsPrec :: Int -> DataColor -> ShowS
Prelude.Show, forall x. Rep DataColor x -> DataColor
forall x. DataColor -> Rep DataColor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataColor x -> DataColor
$cfrom :: forall x. DataColor -> Rep DataColor x
Prelude.Generic)

-- |
-- Create a value of 'DataColor' 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:
--
-- 'color', 'dataColor_color' - The color that is applied to the data value.
--
-- 'dataValue', 'dataColor_dataValue' - The data value that the color is applied to.
newDataColor ::
  DataColor
newDataColor :: DataColor
newDataColor =
  DataColor'
    { $sel:color:DataColor' :: Maybe Text
color = forall a. Maybe a
Prelude.Nothing,
      $sel:dataValue:DataColor' :: Maybe Double
dataValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The color that is applied to the data value.
dataColor_color :: Lens.Lens' DataColor (Prelude.Maybe Prelude.Text)
dataColor_color :: Lens' DataColor (Maybe Text)
dataColor_color = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataColor' {Maybe Text
color :: Maybe Text
$sel:color:DataColor' :: DataColor -> Maybe Text
color} -> Maybe Text
color) (\s :: DataColor
s@DataColor' {} Maybe Text
a -> DataColor
s {$sel:color:DataColor' :: Maybe Text
color = Maybe Text
a} :: DataColor)

-- | The data value that the color is applied to.
dataColor_dataValue :: Lens.Lens' DataColor (Prelude.Maybe Prelude.Double)
dataColor_dataValue :: Lens' DataColor (Maybe Double)
dataColor_dataValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataColor' {Maybe Double
dataValue :: Maybe Double
$sel:dataValue:DataColor' :: DataColor -> Maybe Double
dataValue} -> Maybe Double
dataValue) (\s :: DataColor
s@DataColor' {} Maybe Double
a -> DataColor
s {$sel:dataValue:DataColor' :: Maybe Double
dataValue = Maybe Double
a} :: DataColor)

instance Data.FromJSON DataColor where
  parseJSON :: Value -> Parser DataColor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataColor"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> DataColor
DataColor'
            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
"Color")
            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
"DataValue")
      )

instance Prelude.Hashable DataColor where
  hashWithSalt :: Int -> DataColor -> Int
hashWithSalt Int
_salt DataColor' {Maybe Double
Maybe Text
dataValue :: Maybe Double
color :: Maybe Text
$sel:dataValue:DataColor' :: DataColor -> Maybe Double
$sel:color:DataColor' :: DataColor -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
color
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
dataValue

instance Prelude.NFData DataColor where
  rnf :: DataColor -> ()
rnf DataColor' {Maybe Double
Maybe Text
dataValue :: Maybe Double
color :: Maybe Text
$sel:dataValue:DataColor' :: DataColor -> Maybe Double
$sel:color:DataColor' :: DataColor -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
color
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
dataValue

instance Data.ToJSON DataColor where
  toJSON :: DataColor -> Value
toJSON DataColor' {Maybe Double
Maybe Text
dataValue :: Maybe Double
color :: Maybe Text
$sel:dataValue:DataColor' :: DataColor -> Maybe Double
$sel:color:DataColor' :: DataColor -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Color" 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 Text
color,
            (Key
"DataValue" 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
dataValue
          ]
      )