{-# 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.FilledMapShapeConditionalFormatting
-- 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.FilledMapShapeConditionalFormatting 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.ShapeConditionalFormat

-- | The conditional formatting that determines the shape of the filled map.
--
-- /See:/ 'newFilledMapShapeConditionalFormatting' smart constructor.
data FilledMapShapeConditionalFormatting = FilledMapShapeConditionalFormatting'
  { -- | The conditional formatting that determines the background color of a
    -- filled map\'s shape.
    FilledMapShapeConditionalFormatting -> Maybe ShapeConditionalFormat
format :: Prelude.Maybe ShapeConditionalFormat,
    -- | The field ID of the filled map shape.
    FilledMapShapeConditionalFormatting -> Text
fieldId :: Prelude.Text
  }
  deriving (FilledMapShapeConditionalFormatting
-> FilledMapShapeConditionalFormatting -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilledMapShapeConditionalFormatting
-> FilledMapShapeConditionalFormatting -> Bool
$c/= :: FilledMapShapeConditionalFormatting
-> FilledMapShapeConditionalFormatting -> Bool
== :: FilledMapShapeConditionalFormatting
-> FilledMapShapeConditionalFormatting -> Bool
$c== :: FilledMapShapeConditionalFormatting
-> FilledMapShapeConditionalFormatting -> Bool
Prelude.Eq, Int -> FilledMapShapeConditionalFormatting -> ShowS
[FilledMapShapeConditionalFormatting] -> ShowS
FilledMapShapeConditionalFormatting -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilledMapShapeConditionalFormatting] -> ShowS
$cshowList :: [FilledMapShapeConditionalFormatting] -> ShowS
show :: FilledMapShapeConditionalFormatting -> String
$cshow :: FilledMapShapeConditionalFormatting -> String
showsPrec :: Int -> FilledMapShapeConditionalFormatting -> ShowS
$cshowsPrec :: Int -> FilledMapShapeConditionalFormatting -> ShowS
Prelude.Show, forall x.
Rep FilledMapShapeConditionalFormatting x
-> FilledMapShapeConditionalFormatting
forall x.
FilledMapShapeConditionalFormatting
-> Rep FilledMapShapeConditionalFormatting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FilledMapShapeConditionalFormatting x
-> FilledMapShapeConditionalFormatting
$cfrom :: forall x.
FilledMapShapeConditionalFormatting
-> Rep FilledMapShapeConditionalFormatting x
Prelude.Generic)

-- |
-- Create a value of 'FilledMapShapeConditionalFormatting' 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:
--
-- 'format', 'filledMapShapeConditionalFormatting_format' - The conditional formatting that determines the background color of a
-- filled map\'s shape.
--
-- 'fieldId', 'filledMapShapeConditionalFormatting_fieldId' - The field ID of the filled map shape.
newFilledMapShapeConditionalFormatting ::
  -- | 'fieldId'
  Prelude.Text ->
  FilledMapShapeConditionalFormatting
newFilledMapShapeConditionalFormatting :: Text -> FilledMapShapeConditionalFormatting
newFilledMapShapeConditionalFormatting Text
pFieldId_ =
  FilledMapShapeConditionalFormatting'
    { $sel:format:FilledMapShapeConditionalFormatting' :: Maybe ShapeConditionalFormat
format =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fieldId:FilledMapShapeConditionalFormatting' :: Text
fieldId = Text
pFieldId_
    }

-- | The conditional formatting that determines the background color of a
-- filled map\'s shape.
filledMapShapeConditionalFormatting_format :: Lens.Lens' FilledMapShapeConditionalFormatting (Prelude.Maybe ShapeConditionalFormat)
filledMapShapeConditionalFormatting_format :: Lens'
  FilledMapShapeConditionalFormatting (Maybe ShapeConditionalFormat)
filledMapShapeConditionalFormatting_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilledMapShapeConditionalFormatting' {Maybe ShapeConditionalFormat
format :: Maybe ShapeConditionalFormat
$sel:format:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Maybe ShapeConditionalFormat
format} -> Maybe ShapeConditionalFormat
format) (\s :: FilledMapShapeConditionalFormatting
s@FilledMapShapeConditionalFormatting' {} Maybe ShapeConditionalFormat
a -> FilledMapShapeConditionalFormatting
s {$sel:format:FilledMapShapeConditionalFormatting' :: Maybe ShapeConditionalFormat
format = Maybe ShapeConditionalFormat
a} :: FilledMapShapeConditionalFormatting)

-- | The field ID of the filled map shape.
filledMapShapeConditionalFormatting_fieldId :: Lens.Lens' FilledMapShapeConditionalFormatting Prelude.Text
filledMapShapeConditionalFormatting_fieldId :: Lens' FilledMapShapeConditionalFormatting Text
filledMapShapeConditionalFormatting_fieldId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilledMapShapeConditionalFormatting' {Text
fieldId :: Text
$sel:fieldId:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Text
fieldId} -> Text
fieldId) (\s :: FilledMapShapeConditionalFormatting
s@FilledMapShapeConditionalFormatting' {} Text
a -> FilledMapShapeConditionalFormatting
s {$sel:fieldId:FilledMapShapeConditionalFormatting' :: Text
fieldId = Text
a} :: FilledMapShapeConditionalFormatting)

instance
  Data.FromJSON
    FilledMapShapeConditionalFormatting
  where
  parseJSON :: Value -> Parser FilledMapShapeConditionalFormatting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FilledMapShapeConditionalFormatting"
      ( \Object
x ->
          Maybe ShapeConditionalFormat
-> Text -> FilledMapShapeConditionalFormatting
FilledMapShapeConditionalFormatting'
            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
"Format")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FieldId")
      )

instance
  Prelude.Hashable
    FilledMapShapeConditionalFormatting
  where
  hashWithSalt :: Int -> FilledMapShapeConditionalFormatting -> Int
hashWithSalt
    Int
_salt
    FilledMapShapeConditionalFormatting' {Maybe ShapeConditionalFormat
Text
fieldId :: Text
format :: Maybe ShapeConditionalFormat
$sel:fieldId:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Text
$sel:format:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Maybe ShapeConditionalFormat
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ShapeConditionalFormat
format
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fieldId

instance
  Prelude.NFData
    FilledMapShapeConditionalFormatting
  where
  rnf :: FilledMapShapeConditionalFormatting -> ()
rnf FilledMapShapeConditionalFormatting' {Maybe ShapeConditionalFormat
Text
fieldId :: Text
format :: Maybe ShapeConditionalFormat
$sel:fieldId:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Text
$sel:format:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Maybe ShapeConditionalFormat
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ShapeConditionalFormat
format
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fieldId

instance
  Data.ToJSON
    FilledMapShapeConditionalFormatting
  where
  toJSON :: FilledMapShapeConditionalFormatting -> Value
toJSON FilledMapShapeConditionalFormatting' {Maybe ShapeConditionalFormat
Text
fieldId :: Text
format :: Maybe ShapeConditionalFormat
$sel:fieldId:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Text
$sel:format:FilledMapShapeConditionalFormatting' :: FilledMapShapeConditionalFormatting -> Maybe ShapeConditionalFormat
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Format" 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 ShapeConditionalFormat
format,
            forall a. a -> Maybe a
Prelude.Just (Key
"FieldId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fieldId)
          ]
      )