{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LexModels.Types.EnumerationValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(EnumerationValue -> EnumerationValue -> Bool)
-> (EnumerationValue -> EnumerationValue -> Bool)
-> Eq EnumerationValue
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]
(Int -> ReadS EnumerationValue)
-> ReadS [EnumerationValue]
-> ReadPrec EnumerationValue
-> ReadPrec [EnumerationValue]
-> Read 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
(Int -> EnumerationValue -> ShowS)
-> (EnumerationValue -> String)
-> ([EnumerationValue] -> ShowS)
-> Show EnumerationValue
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. EnumerationValue -> Rep EnumerationValue x)
-> (forall x. Rep EnumerationValue x -> EnumerationValue)
-> Generic EnumerationValue
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' :: Maybe [Text] -> Text -> EnumerationValue
EnumerationValue'
    { $sel:synonyms:EnumerationValue' :: Maybe [Text]
synonyms = Maybe [Text]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> EnumerationValue -> f EnumerationValue
enumerationValue_synonyms = (EnumerationValue -> Maybe [Text])
-> (EnumerationValue -> Maybe [Text] -> EnumerationValue)
-> Lens
     EnumerationValue EnumerationValue (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> EnumerationValue -> f EnumerationValue)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> EnumerationValue
-> f EnumerationValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Text -> f Text) -> EnumerationValue -> f EnumerationValue
enumerationValue_value = (EnumerationValue -> Text)
-> (EnumerationValue -> Text -> EnumerationValue)
-> Lens EnumerationValue EnumerationValue Text Text
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 Core.FromJSON EnumerationValue where
  parseJSON :: Value -> Parser EnumerationValue
parseJSON =
    String
-> (Object -> Parser EnumerationValue)
-> Value
-> Parser EnumerationValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EnumerationValue"
      ( \Object
x ->
          Maybe [Text] -> Text -> EnumerationValue
EnumerationValue'
            (Maybe [Text] -> Text -> EnumerationValue)
-> Parser (Maybe [Text]) -> Parser (Text -> EnumerationValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"synonyms" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> EnumerationValue)
-> Parser Text -> Parser EnumerationValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"value")
      )

instance Prelude.Hashable EnumerationValue

instance Prelude.NFData EnumerationValue

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"synonyms" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
synonyms,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )