{-# 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.LexModels.Types.EnumerationValue
-- 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.LexModels.Types.EnumerationValue 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

-- | Each slot type can have a set of values. Each enumeration value
-- represents a value the slot type can take.
--
-- For example, a pizza ordering bot could have a slot type that specifies
-- the type of crust that the pizza should have. The slot type could
-- include the values
--
-- -   thick
--
-- -   thin
--
-- -   stuffed
--
-- /See:/ 'newEnumerationValue' smart constructor.
data EnumerationValue = EnumerationValue'
  { -- | Additional values related to the slot type value.
    EnumerationValue -> Maybe [Text]
synonyms :: Prelude.Maybe [Prelude.Text],
    -- | The value of the slot type.
    EnumerationValue -> Text
value :: Prelude.Text
  }
  deriving (EnumerationValue -> EnumerationValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnumerationValue -> EnumerationValue -> Bool
$c/= :: EnumerationValue -> EnumerationValue -> Bool
== :: EnumerationValue -> EnumerationValue -> Bool
$c== :: EnumerationValue -> EnumerationValue -> Bool
Prelude.Eq, ReadPrec [EnumerationValue]
ReadPrec EnumerationValue
Int -> ReadS EnumerationValue
ReadS [EnumerationValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnumerationValue]
$creadListPrec :: ReadPrec [EnumerationValue]
readPrec :: ReadPrec EnumerationValue
$creadPrec :: ReadPrec EnumerationValue
readList :: ReadS [EnumerationValue]
$creadList :: ReadS [EnumerationValue]
readsPrec :: Int -> ReadS EnumerationValue
$creadsPrec :: Int -> ReadS EnumerationValue
Prelude.Read, Int -> EnumerationValue -> ShowS
[EnumerationValue] -> ShowS
EnumerationValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnumerationValue] -> ShowS
$cshowList :: [EnumerationValue] -> ShowS
show :: EnumerationValue -> String
$cshow :: EnumerationValue -> String
showsPrec :: Int -> EnumerationValue -> ShowS
$cshowsPrec :: Int -> EnumerationValue -> ShowS
Prelude.Show, forall x. Rep EnumerationValue x -> EnumerationValue
forall x. EnumerationValue -> Rep EnumerationValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnumerationValue x -> EnumerationValue
$cfrom :: forall x. EnumerationValue -> Rep EnumerationValue x
Prelude.Generic)

-- |
-- Create a value of 'EnumerationValue' 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:
--
-- 'synonyms', 'enumerationValue_synonyms' - Additional values related to the slot type value.
--
-- 'value', 'enumerationValue_value' - The value of the slot type.
newEnumerationValue ::
  -- | 'value'
  Prelude.Text ->
  EnumerationValue
newEnumerationValue :: Text -> EnumerationValue
newEnumerationValue Text
pValue_ =
  EnumerationValue'
    { $sel:synonyms:EnumerationValue' :: Maybe [Text]
synonyms = forall a. Maybe a
Prelude.Nothing,
      $sel:value:EnumerationValue' :: Text
value = Text
pValue_
    }

-- | Additional values related to the slot type value.
enumerationValue_synonyms :: Lens.Lens' EnumerationValue (Prelude.Maybe [Prelude.Text])
enumerationValue_synonyms :: Lens' EnumerationValue (Maybe [Text])
enumerationValue_synonyms = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnumerationValue' {Maybe [Text]
synonyms :: Maybe [Text]
$sel:synonyms:EnumerationValue' :: EnumerationValue -> Maybe [Text]
synonyms} -> Maybe [Text]
synonyms) (\s :: EnumerationValue
s@EnumerationValue' {} Maybe [Text]
a -> EnumerationValue
s {$sel:synonyms:EnumerationValue' :: Maybe [Text]
synonyms = Maybe [Text]
a} :: EnumerationValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The value of the slot type.
enumerationValue_value :: Lens.Lens' EnumerationValue Prelude.Text
enumerationValue_value :: Lens' EnumerationValue Text
enumerationValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnumerationValue' {Text
value :: Text
$sel:value:EnumerationValue' :: EnumerationValue -> Text
value} -> Text
value) (\s :: EnumerationValue
s@EnumerationValue' {} Text
a -> EnumerationValue
s {$sel:value:EnumerationValue' :: Text
value = Text
a} :: EnumerationValue)

instance Data.FromJSON EnumerationValue where
  parseJSON :: Value -> Parser EnumerationValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EnumerationValue"
      ( \Object
x ->
          Maybe [Text] -> Text -> EnumerationValue
EnumerationValue'
            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
"synonyms" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"value")
      )

instance Prelude.Hashable EnumerationValue where
  hashWithSalt :: Int -> EnumerationValue -> Int
hashWithSalt Int
_salt EnumerationValue' {Maybe [Text]
Text
value :: Text
synonyms :: Maybe [Text]
$sel:value:EnumerationValue' :: EnumerationValue -> Text
$sel:synonyms:EnumerationValue' :: EnumerationValue -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
synonyms
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData EnumerationValue where
  rnf :: EnumerationValue -> ()
rnf EnumerationValue' {Maybe [Text]
Text
value :: Text
synonyms :: Maybe [Text]
$sel:value:EnumerationValue' :: EnumerationValue -> Text
$sel:synonyms:EnumerationValue' :: EnumerationValue -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
synonyms
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

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