{-# 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.LexV2Models.Types.SlotTypeValue
-- 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.LexV2Models.Types.SlotTypeValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.SampleValue
import qualified Amazonka.Prelude as Prelude

-- | Each slot type can have a set of values. Each @SlotTypeValue@ represents
-- a value that the slot type can take.
--
-- /See:/ 'newSlotTypeValue' smart constructor.
data SlotTypeValue = SlotTypeValue'
  { -- | The value of the slot type entry.
    SlotTypeValue -> Maybe SampleValue
sampleValue :: Prelude.Maybe SampleValue,
    -- | Additional values related to the slot type entry.
    SlotTypeValue -> Maybe (NonEmpty SampleValue)
synonyms :: Prelude.Maybe (Prelude.NonEmpty SampleValue)
  }
  deriving (SlotTypeValue -> SlotTypeValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotTypeValue -> SlotTypeValue -> Bool
$c/= :: SlotTypeValue -> SlotTypeValue -> Bool
== :: SlotTypeValue -> SlotTypeValue -> Bool
$c== :: SlotTypeValue -> SlotTypeValue -> Bool
Prelude.Eq, ReadPrec [SlotTypeValue]
ReadPrec SlotTypeValue
Int -> ReadS SlotTypeValue
ReadS [SlotTypeValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotTypeValue]
$creadListPrec :: ReadPrec [SlotTypeValue]
readPrec :: ReadPrec SlotTypeValue
$creadPrec :: ReadPrec SlotTypeValue
readList :: ReadS [SlotTypeValue]
$creadList :: ReadS [SlotTypeValue]
readsPrec :: Int -> ReadS SlotTypeValue
$creadsPrec :: Int -> ReadS SlotTypeValue
Prelude.Read, Int -> SlotTypeValue -> ShowS
[SlotTypeValue] -> ShowS
SlotTypeValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotTypeValue] -> ShowS
$cshowList :: [SlotTypeValue] -> ShowS
show :: SlotTypeValue -> String
$cshow :: SlotTypeValue -> String
showsPrec :: Int -> SlotTypeValue -> ShowS
$cshowsPrec :: Int -> SlotTypeValue -> ShowS
Prelude.Show, forall x. Rep SlotTypeValue x -> SlotTypeValue
forall x. SlotTypeValue -> Rep SlotTypeValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotTypeValue x -> SlotTypeValue
$cfrom :: forall x. SlotTypeValue -> Rep SlotTypeValue x
Prelude.Generic)

-- |
-- Create a value of 'SlotTypeValue' 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:
--
-- 'sampleValue', 'slotTypeValue_sampleValue' - The value of the slot type entry.
--
-- 'synonyms', 'slotTypeValue_synonyms' - Additional values related to the slot type entry.
newSlotTypeValue ::
  SlotTypeValue
newSlotTypeValue :: SlotTypeValue
newSlotTypeValue =
  SlotTypeValue'
    { $sel:sampleValue:SlotTypeValue' :: Maybe SampleValue
sampleValue = forall a. Maybe a
Prelude.Nothing,
      $sel:synonyms:SlotTypeValue' :: Maybe (NonEmpty SampleValue)
synonyms = forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the slot type entry.
slotTypeValue_sampleValue :: Lens.Lens' SlotTypeValue (Prelude.Maybe SampleValue)
slotTypeValue_sampleValue :: Lens' SlotTypeValue (Maybe SampleValue)
slotTypeValue_sampleValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeValue' {Maybe SampleValue
sampleValue :: Maybe SampleValue
$sel:sampleValue:SlotTypeValue' :: SlotTypeValue -> Maybe SampleValue
sampleValue} -> Maybe SampleValue
sampleValue) (\s :: SlotTypeValue
s@SlotTypeValue' {} Maybe SampleValue
a -> SlotTypeValue
s {$sel:sampleValue:SlotTypeValue' :: Maybe SampleValue
sampleValue = Maybe SampleValue
a} :: SlotTypeValue)

-- | Additional values related to the slot type entry.
slotTypeValue_synonyms :: Lens.Lens' SlotTypeValue (Prelude.Maybe (Prelude.NonEmpty SampleValue))
slotTypeValue_synonyms :: Lens' SlotTypeValue (Maybe (NonEmpty SampleValue))
slotTypeValue_synonyms = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeValue' {Maybe (NonEmpty SampleValue)
synonyms :: Maybe (NonEmpty SampleValue)
$sel:synonyms:SlotTypeValue' :: SlotTypeValue -> Maybe (NonEmpty SampleValue)
synonyms} -> Maybe (NonEmpty SampleValue)
synonyms) (\s :: SlotTypeValue
s@SlotTypeValue' {} Maybe (NonEmpty SampleValue)
a -> SlotTypeValue
s {$sel:synonyms:SlotTypeValue' :: Maybe (NonEmpty SampleValue)
synonyms = Maybe (NonEmpty SampleValue)
a} :: SlotTypeValue) 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

instance Data.FromJSON SlotTypeValue where
  parseJSON :: Value -> Parser SlotTypeValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SlotTypeValue"
      ( \Object
x ->
          Maybe SampleValue -> Maybe (NonEmpty SampleValue) -> SlotTypeValue
SlotTypeValue'
            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
"sampleValue")
            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
"synonyms")
      )

instance Prelude.Hashable SlotTypeValue where
  hashWithSalt :: Int -> SlotTypeValue -> Int
hashWithSalt Int
_salt SlotTypeValue' {Maybe (NonEmpty SampleValue)
Maybe SampleValue
synonyms :: Maybe (NonEmpty SampleValue)
sampleValue :: Maybe SampleValue
$sel:synonyms:SlotTypeValue' :: SlotTypeValue -> Maybe (NonEmpty SampleValue)
$sel:sampleValue:SlotTypeValue' :: SlotTypeValue -> Maybe SampleValue
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SampleValue
sampleValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty SampleValue)
synonyms

instance Prelude.NFData SlotTypeValue where
  rnf :: SlotTypeValue -> ()
rnf SlotTypeValue' {Maybe (NonEmpty SampleValue)
Maybe SampleValue
synonyms :: Maybe (NonEmpty SampleValue)
sampleValue :: Maybe SampleValue
$sel:synonyms:SlotTypeValue' :: SlotTypeValue -> Maybe (NonEmpty SampleValue)
$sel:sampleValue:SlotTypeValue' :: SlotTypeValue -> Maybe SampleValue
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SampleValue
sampleValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty SampleValue)
synonyms

instance Data.ToJSON SlotTypeValue where
  toJSON :: SlotTypeValue -> Value
toJSON SlotTypeValue' {Maybe (NonEmpty SampleValue)
Maybe SampleValue
synonyms :: Maybe (NonEmpty SampleValue)
sampleValue :: Maybe SampleValue
$sel:synonyms:SlotTypeValue' :: SlotTypeValue -> Maybe (NonEmpty SampleValue)
$sel:sampleValue:SlotTypeValue' :: SlotTypeValue -> Maybe SampleValue
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"sampleValue" 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 SampleValue
sampleValue,
            (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 (NonEmpty SampleValue)
synonyms
          ]
      )