{-# 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.TableRowConditionalFormatting
-- 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.TableRowConditionalFormatting 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.ConditionalFormattingColor

-- | The conditional formatting of a table row.
--
-- /See:/ 'newTableRowConditionalFormatting' smart constructor.
data TableRowConditionalFormatting = TableRowConditionalFormatting'
  { -- | The conditional formatting color (solid, gradient) of the background for
    -- a table row.
    TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
backgroundColor :: Prelude.Maybe ConditionalFormattingColor,
    -- | The conditional formatting color (solid, gradient) of the text for a
    -- table row.
    TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
textColor :: Prelude.Maybe ConditionalFormattingColor
  }
  deriving (TableRowConditionalFormatting
-> TableRowConditionalFormatting -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableRowConditionalFormatting
-> TableRowConditionalFormatting -> Bool
$c/= :: TableRowConditionalFormatting
-> TableRowConditionalFormatting -> Bool
== :: TableRowConditionalFormatting
-> TableRowConditionalFormatting -> Bool
$c== :: TableRowConditionalFormatting
-> TableRowConditionalFormatting -> Bool
Prelude.Eq, Int -> TableRowConditionalFormatting -> ShowS
[TableRowConditionalFormatting] -> ShowS
TableRowConditionalFormatting -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableRowConditionalFormatting] -> ShowS
$cshowList :: [TableRowConditionalFormatting] -> ShowS
show :: TableRowConditionalFormatting -> String
$cshow :: TableRowConditionalFormatting -> String
showsPrec :: Int -> TableRowConditionalFormatting -> ShowS
$cshowsPrec :: Int -> TableRowConditionalFormatting -> ShowS
Prelude.Show, forall x.
Rep TableRowConditionalFormatting x
-> TableRowConditionalFormatting
forall x.
TableRowConditionalFormatting
-> Rep TableRowConditionalFormatting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TableRowConditionalFormatting x
-> TableRowConditionalFormatting
$cfrom :: forall x.
TableRowConditionalFormatting
-> Rep TableRowConditionalFormatting x
Prelude.Generic)

-- |
-- Create a value of 'TableRowConditionalFormatting' 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:
--
-- 'backgroundColor', 'tableRowConditionalFormatting_backgroundColor' - The conditional formatting color (solid, gradient) of the background for
-- a table row.
--
-- 'textColor', 'tableRowConditionalFormatting_textColor' - The conditional formatting color (solid, gradient) of the text for a
-- table row.
newTableRowConditionalFormatting ::
  TableRowConditionalFormatting
newTableRowConditionalFormatting :: TableRowConditionalFormatting
newTableRowConditionalFormatting =
  TableRowConditionalFormatting'
    { $sel:backgroundColor:TableRowConditionalFormatting' :: Maybe ConditionalFormattingColor
backgroundColor =
        forall a. Maybe a
Prelude.Nothing,
      $sel:textColor:TableRowConditionalFormatting' :: Maybe ConditionalFormattingColor
textColor = forall a. Maybe a
Prelude.Nothing
    }

-- | The conditional formatting color (solid, gradient) of the background for
-- a table row.
tableRowConditionalFormatting_backgroundColor :: Lens.Lens' TableRowConditionalFormatting (Prelude.Maybe ConditionalFormattingColor)
tableRowConditionalFormatting_backgroundColor :: Lens'
  TableRowConditionalFormatting (Maybe ConditionalFormattingColor)
tableRowConditionalFormatting_backgroundColor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableRowConditionalFormatting' {Maybe ConditionalFormattingColor
backgroundColor :: Maybe ConditionalFormattingColor
$sel:backgroundColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
backgroundColor} -> Maybe ConditionalFormattingColor
backgroundColor) (\s :: TableRowConditionalFormatting
s@TableRowConditionalFormatting' {} Maybe ConditionalFormattingColor
a -> TableRowConditionalFormatting
s {$sel:backgroundColor:TableRowConditionalFormatting' :: Maybe ConditionalFormattingColor
backgroundColor = Maybe ConditionalFormattingColor
a} :: TableRowConditionalFormatting)

-- | The conditional formatting color (solid, gradient) of the text for a
-- table row.
tableRowConditionalFormatting_textColor :: Lens.Lens' TableRowConditionalFormatting (Prelude.Maybe ConditionalFormattingColor)
tableRowConditionalFormatting_textColor :: Lens'
  TableRowConditionalFormatting (Maybe ConditionalFormattingColor)
tableRowConditionalFormatting_textColor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableRowConditionalFormatting' {Maybe ConditionalFormattingColor
textColor :: Maybe ConditionalFormattingColor
$sel:textColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
textColor} -> Maybe ConditionalFormattingColor
textColor) (\s :: TableRowConditionalFormatting
s@TableRowConditionalFormatting' {} Maybe ConditionalFormattingColor
a -> TableRowConditionalFormatting
s {$sel:textColor:TableRowConditionalFormatting' :: Maybe ConditionalFormattingColor
textColor = Maybe ConditionalFormattingColor
a} :: TableRowConditionalFormatting)

instance Data.FromJSON TableRowConditionalFormatting where
  parseJSON :: Value -> Parser TableRowConditionalFormatting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TableRowConditionalFormatting"
      ( \Object
x ->
          Maybe ConditionalFormattingColor
-> Maybe ConditionalFormattingColor
-> TableRowConditionalFormatting
TableRowConditionalFormatting'
            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
"BackgroundColor")
            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
"TextColor")
      )

instance
  Prelude.Hashable
    TableRowConditionalFormatting
  where
  hashWithSalt :: Int -> TableRowConditionalFormatting -> Int
hashWithSalt Int
_salt TableRowConditionalFormatting' {Maybe ConditionalFormattingColor
textColor :: Maybe ConditionalFormattingColor
backgroundColor :: Maybe ConditionalFormattingColor
$sel:textColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
$sel:backgroundColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConditionalFormattingColor
backgroundColor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConditionalFormattingColor
textColor

instance Prelude.NFData TableRowConditionalFormatting where
  rnf :: TableRowConditionalFormatting -> ()
rnf TableRowConditionalFormatting' {Maybe ConditionalFormattingColor
textColor :: Maybe ConditionalFormattingColor
backgroundColor :: Maybe ConditionalFormattingColor
$sel:textColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
$sel:backgroundColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ConditionalFormattingColor
backgroundColor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConditionalFormattingColor
textColor

instance Data.ToJSON TableRowConditionalFormatting where
  toJSON :: TableRowConditionalFormatting -> Value
toJSON TableRowConditionalFormatting' {Maybe ConditionalFormattingColor
textColor :: Maybe ConditionalFormattingColor
backgroundColor :: Maybe ConditionalFormattingColor
$sel:textColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
$sel:backgroundColor:TableRowConditionalFormatting' :: TableRowConditionalFormatting -> Maybe ConditionalFormattingColor
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BackgroundColor" 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 ConditionalFormattingColor
backgroundColor,
            (Key
"TextColor" 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 ConditionalFormattingColor
textColor
          ]
      )