{-# 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.ConnectCases.Types.FieldValueUnion
-- 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.ConnectCases.Types.FieldValueUnion 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

-- | Object to store union of Field values.
--
-- /See:/ 'newFieldValueUnion' smart constructor.
data FieldValueUnion = FieldValueUnion'
  { -- | Can be either null, or have a Boolean value type. Only one value can be
    -- provided.
    FieldValueUnion -> Maybe Bool
booleanValue :: Prelude.Maybe Prelude.Bool,
    -- | Can be either null, or have a Double number value type. Only one value
    -- can be provided.
    FieldValueUnion -> Maybe Double
doubleValue :: Prelude.Maybe Prelude.Double,
    -- | String value type.
    FieldValueUnion -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text
  }
  deriving (FieldValueUnion -> FieldValueUnion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldValueUnion -> FieldValueUnion -> Bool
$c/= :: FieldValueUnion -> FieldValueUnion -> Bool
== :: FieldValueUnion -> FieldValueUnion -> Bool
$c== :: FieldValueUnion -> FieldValueUnion -> Bool
Prelude.Eq, ReadPrec [FieldValueUnion]
ReadPrec FieldValueUnion
Int -> ReadS FieldValueUnion
ReadS [FieldValueUnion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldValueUnion]
$creadListPrec :: ReadPrec [FieldValueUnion]
readPrec :: ReadPrec FieldValueUnion
$creadPrec :: ReadPrec FieldValueUnion
readList :: ReadS [FieldValueUnion]
$creadList :: ReadS [FieldValueUnion]
readsPrec :: Int -> ReadS FieldValueUnion
$creadsPrec :: Int -> ReadS FieldValueUnion
Prelude.Read, Int -> FieldValueUnion -> ShowS
[FieldValueUnion] -> ShowS
FieldValueUnion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldValueUnion] -> ShowS
$cshowList :: [FieldValueUnion] -> ShowS
show :: FieldValueUnion -> String
$cshow :: FieldValueUnion -> String
showsPrec :: Int -> FieldValueUnion -> ShowS
$cshowsPrec :: Int -> FieldValueUnion -> ShowS
Prelude.Show, forall x. Rep FieldValueUnion x -> FieldValueUnion
forall x. FieldValueUnion -> Rep FieldValueUnion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FieldValueUnion x -> FieldValueUnion
$cfrom :: forall x. FieldValueUnion -> Rep FieldValueUnion x
Prelude.Generic)

-- |
-- Create a value of 'FieldValueUnion' 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:
--
-- 'booleanValue', 'fieldValueUnion_booleanValue' - Can be either null, or have a Boolean value type. Only one value can be
-- provided.
--
-- 'doubleValue', 'fieldValueUnion_doubleValue' - Can be either null, or have a Double number value type. Only one value
-- can be provided.
--
-- 'stringValue', 'fieldValueUnion_stringValue' - String value type.
newFieldValueUnion ::
  FieldValueUnion
newFieldValueUnion :: FieldValueUnion
newFieldValueUnion =
  FieldValueUnion'
    { $sel:booleanValue:FieldValueUnion' :: Maybe Bool
booleanValue = forall a. Maybe a
Prelude.Nothing,
      $sel:doubleValue:FieldValueUnion' :: Maybe Double
doubleValue = forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:FieldValueUnion' :: Maybe Text
stringValue = forall a. Maybe a
Prelude.Nothing
    }

-- | Can be either null, or have a Boolean value type. Only one value can be
-- provided.
fieldValueUnion_booleanValue :: Lens.Lens' FieldValueUnion (Prelude.Maybe Prelude.Bool)
fieldValueUnion_booleanValue :: Lens' FieldValueUnion (Maybe Bool)
fieldValueUnion_booleanValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldValueUnion' {Maybe Bool
booleanValue :: Maybe Bool
$sel:booleanValue:FieldValueUnion' :: FieldValueUnion -> Maybe Bool
booleanValue} -> Maybe Bool
booleanValue) (\s :: FieldValueUnion
s@FieldValueUnion' {} Maybe Bool
a -> FieldValueUnion
s {$sel:booleanValue:FieldValueUnion' :: Maybe Bool
booleanValue = Maybe Bool
a} :: FieldValueUnion)

-- | Can be either null, or have a Double number value type. Only one value
-- can be provided.
fieldValueUnion_doubleValue :: Lens.Lens' FieldValueUnion (Prelude.Maybe Prelude.Double)
fieldValueUnion_doubleValue :: Lens' FieldValueUnion (Maybe Double)
fieldValueUnion_doubleValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldValueUnion' {Maybe Double
doubleValue :: Maybe Double
$sel:doubleValue:FieldValueUnion' :: FieldValueUnion -> Maybe Double
doubleValue} -> Maybe Double
doubleValue) (\s :: FieldValueUnion
s@FieldValueUnion' {} Maybe Double
a -> FieldValueUnion
s {$sel:doubleValue:FieldValueUnion' :: Maybe Double
doubleValue = Maybe Double
a} :: FieldValueUnion)

-- | String value type.
fieldValueUnion_stringValue :: Lens.Lens' FieldValueUnion (Prelude.Maybe Prelude.Text)
fieldValueUnion_stringValue :: Lens' FieldValueUnion (Maybe Text)
fieldValueUnion_stringValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldValueUnion' {Maybe Text
stringValue :: Maybe Text
$sel:stringValue:FieldValueUnion' :: FieldValueUnion -> Maybe Text
stringValue} -> Maybe Text
stringValue) (\s :: FieldValueUnion
s@FieldValueUnion' {} Maybe Text
a -> FieldValueUnion
s {$sel:stringValue:FieldValueUnion' :: Maybe Text
stringValue = Maybe Text
a} :: FieldValueUnion)

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

instance Prelude.Hashable FieldValueUnion where
  hashWithSalt :: Int -> FieldValueUnion -> Int
hashWithSalt Int
_salt FieldValueUnion' {Maybe Bool
Maybe Double
Maybe Text
stringValue :: Maybe Text
doubleValue :: Maybe Double
booleanValue :: Maybe Bool
$sel:stringValue:FieldValueUnion' :: FieldValueUnion -> Maybe Text
$sel:doubleValue:FieldValueUnion' :: FieldValueUnion -> Maybe Double
$sel:booleanValue:FieldValueUnion' :: FieldValueUnion -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
booleanValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
doubleValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stringValue

instance Prelude.NFData FieldValueUnion where
  rnf :: FieldValueUnion -> ()
rnf FieldValueUnion' {Maybe Bool
Maybe Double
Maybe Text
stringValue :: Maybe Text
doubleValue :: Maybe Double
booleanValue :: Maybe Bool
$sel:stringValue:FieldValueUnion' :: FieldValueUnion -> Maybe Text
$sel:doubleValue:FieldValueUnion' :: FieldValueUnion -> Maybe Double
$sel:booleanValue:FieldValueUnion' :: FieldValueUnion -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
booleanValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
doubleValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stringValue

instance Data.ToJSON FieldValueUnion where
  toJSON :: FieldValueUnion -> Value
toJSON FieldValueUnion' {Maybe Bool
Maybe Double
Maybe Text
stringValue :: Maybe Text
doubleValue :: Maybe Double
booleanValue :: Maybe Bool
$sel:stringValue:FieldValueUnion' :: FieldValueUnion -> Maybe Text
$sel:doubleValue:FieldValueUnion' :: FieldValueUnion -> Maybe Double
$sel:booleanValue:FieldValueUnion' :: FieldValueUnion -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"booleanValue" 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 Bool
booleanValue,
            (Key
"doubleValue" 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
doubleValue,
            (Key
"stringValue" 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
stringValue
          ]
      )