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

-- | The text format for a subtitle.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newLongFormatText' smart constructor.
data LongFormatText = LongFormatText'
  { -- | Plain text format.
    LongFormatText -> Maybe Text
plainText :: Prelude.Maybe Prelude.Text,
    -- | Rich text. Examples of rich text include bold, underline, and italics.
    LongFormatText -> Maybe Text
richText :: Prelude.Maybe Prelude.Text
  }
  deriving (LongFormatText -> LongFormatText -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LongFormatText -> LongFormatText -> Bool
$c/= :: LongFormatText -> LongFormatText -> Bool
== :: LongFormatText -> LongFormatText -> Bool
$c== :: LongFormatText -> LongFormatText -> Bool
Prelude.Eq, ReadPrec [LongFormatText]
ReadPrec LongFormatText
Int -> ReadS LongFormatText
ReadS [LongFormatText]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LongFormatText]
$creadListPrec :: ReadPrec [LongFormatText]
readPrec :: ReadPrec LongFormatText
$creadPrec :: ReadPrec LongFormatText
readList :: ReadS [LongFormatText]
$creadList :: ReadS [LongFormatText]
readsPrec :: Int -> ReadS LongFormatText
$creadsPrec :: Int -> ReadS LongFormatText
Prelude.Read, Int -> LongFormatText -> ShowS
[LongFormatText] -> ShowS
LongFormatText -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LongFormatText] -> ShowS
$cshowList :: [LongFormatText] -> ShowS
show :: LongFormatText -> String
$cshow :: LongFormatText -> String
showsPrec :: Int -> LongFormatText -> ShowS
$cshowsPrec :: Int -> LongFormatText -> ShowS
Prelude.Show, forall x. Rep LongFormatText x -> LongFormatText
forall x. LongFormatText -> Rep LongFormatText x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LongFormatText x -> LongFormatText
$cfrom :: forall x. LongFormatText -> Rep LongFormatText x
Prelude.Generic)

-- |
-- Create a value of 'LongFormatText' 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:
--
-- 'plainText', 'longFormatText_plainText' - Plain text format.
--
-- 'richText', 'longFormatText_richText' - Rich text. Examples of rich text include bold, underline, and italics.
newLongFormatText ::
  LongFormatText
newLongFormatText :: LongFormatText
newLongFormatText =
  LongFormatText'
    { $sel:plainText:LongFormatText' :: Maybe Text
plainText = forall a. Maybe a
Prelude.Nothing,
      $sel:richText:LongFormatText' :: Maybe Text
richText = forall a. Maybe a
Prelude.Nothing
    }

-- | Plain text format.
longFormatText_plainText :: Lens.Lens' LongFormatText (Prelude.Maybe Prelude.Text)
longFormatText_plainText :: Lens' LongFormatText (Maybe Text)
longFormatText_plainText = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LongFormatText' {Maybe Text
plainText :: Maybe Text
$sel:plainText:LongFormatText' :: LongFormatText -> Maybe Text
plainText} -> Maybe Text
plainText) (\s :: LongFormatText
s@LongFormatText' {} Maybe Text
a -> LongFormatText
s {$sel:plainText:LongFormatText' :: Maybe Text
plainText = Maybe Text
a} :: LongFormatText)

-- | Rich text. Examples of rich text include bold, underline, and italics.
longFormatText_richText :: Lens.Lens' LongFormatText (Prelude.Maybe Prelude.Text)
longFormatText_richText :: Lens' LongFormatText (Maybe Text)
longFormatText_richText = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LongFormatText' {Maybe Text
richText :: Maybe Text
$sel:richText:LongFormatText' :: LongFormatText -> Maybe Text
richText} -> Maybe Text
richText) (\s :: LongFormatText
s@LongFormatText' {} Maybe Text
a -> LongFormatText
s {$sel:richText:LongFormatText' :: Maybe Text
richText = Maybe Text
a} :: LongFormatText)

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

instance Prelude.Hashable LongFormatText where
  hashWithSalt :: Int -> LongFormatText -> Int
hashWithSalt Int
_salt LongFormatText' {Maybe Text
richText :: Maybe Text
plainText :: Maybe Text
$sel:richText:LongFormatText' :: LongFormatText -> Maybe Text
$sel:plainText:LongFormatText' :: LongFormatText -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
plainText
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
richText

instance Prelude.NFData LongFormatText where
  rnf :: LongFormatText -> ()
rnf LongFormatText' {Maybe Text
richText :: Maybe Text
plainText :: Maybe Text
$sel:richText:LongFormatText' :: LongFormatText -> Maybe Text
$sel:plainText:LongFormatText' :: LongFormatText -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
plainText
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
richText

instance Data.ToJSON LongFormatText where
  toJSON :: LongFormatText -> Value
toJSON LongFormatText' {Maybe Text
richText :: Maybe Text
plainText :: Maybe Text
$sel:richText:LongFormatText' :: LongFormatText -> Maybe Text
$sel:plainText:LongFormatText' :: LongFormatText -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"PlainText" 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
plainText,
            (Key
"RichText" 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
richText
          ]
      )