{-# 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.SubSlotSetting
-- 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.SubSlotSetting 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.Specifications
import qualified Amazonka.Prelude as Prelude

-- | Specifications for the constituent sub slots and the expression for the
-- composite slot.
--
-- /See:/ 'newSubSlotSetting' smart constructor.
data SubSlotSetting = SubSlotSetting'
  { -- | The expression text for defining the constituent sub slots in the
    -- composite slot using logical AND and OR operators.
    SubSlotSetting -> Maybe Text
expression :: Prelude.Maybe Prelude.Text,
    -- | Specifications for the constituent sub slots of a composite slot.
    SubSlotSetting -> Maybe (HashMap Text Specifications)
slotSpecifications :: Prelude.Maybe (Prelude.HashMap Prelude.Text Specifications)
  }
  deriving (SubSlotSetting -> SubSlotSetting -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubSlotSetting -> SubSlotSetting -> Bool
$c/= :: SubSlotSetting -> SubSlotSetting -> Bool
== :: SubSlotSetting -> SubSlotSetting -> Bool
$c== :: SubSlotSetting -> SubSlotSetting -> Bool
Prelude.Eq, ReadPrec [SubSlotSetting]
ReadPrec SubSlotSetting
Int -> ReadS SubSlotSetting
ReadS [SubSlotSetting]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubSlotSetting]
$creadListPrec :: ReadPrec [SubSlotSetting]
readPrec :: ReadPrec SubSlotSetting
$creadPrec :: ReadPrec SubSlotSetting
readList :: ReadS [SubSlotSetting]
$creadList :: ReadS [SubSlotSetting]
readsPrec :: Int -> ReadS SubSlotSetting
$creadsPrec :: Int -> ReadS SubSlotSetting
Prelude.Read, Int -> SubSlotSetting -> ShowS
[SubSlotSetting] -> ShowS
SubSlotSetting -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubSlotSetting] -> ShowS
$cshowList :: [SubSlotSetting] -> ShowS
show :: SubSlotSetting -> String
$cshow :: SubSlotSetting -> String
showsPrec :: Int -> SubSlotSetting -> ShowS
$cshowsPrec :: Int -> SubSlotSetting -> ShowS
Prelude.Show, forall x. Rep SubSlotSetting x -> SubSlotSetting
forall x. SubSlotSetting -> Rep SubSlotSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubSlotSetting x -> SubSlotSetting
$cfrom :: forall x. SubSlotSetting -> Rep SubSlotSetting x
Prelude.Generic)

-- |
-- Create a value of 'SubSlotSetting' 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:
--
-- 'expression', 'subSlotSetting_expression' - The expression text for defining the constituent sub slots in the
-- composite slot using logical AND and OR operators.
--
-- 'slotSpecifications', 'subSlotSetting_slotSpecifications' - Specifications for the constituent sub slots of a composite slot.
newSubSlotSetting ::
  SubSlotSetting
newSubSlotSetting :: SubSlotSetting
newSubSlotSetting =
  SubSlotSetting'
    { $sel:expression:SubSlotSetting' :: Maybe Text
expression = forall a. Maybe a
Prelude.Nothing,
      $sel:slotSpecifications:SubSlotSetting' :: Maybe (HashMap Text Specifications)
slotSpecifications = forall a. Maybe a
Prelude.Nothing
    }

-- | The expression text for defining the constituent sub slots in the
-- composite slot using logical AND and OR operators.
subSlotSetting_expression :: Lens.Lens' SubSlotSetting (Prelude.Maybe Prelude.Text)
subSlotSetting_expression :: Lens' SubSlotSetting (Maybe Text)
subSlotSetting_expression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubSlotSetting' {Maybe Text
expression :: Maybe Text
$sel:expression:SubSlotSetting' :: SubSlotSetting -> Maybe Text
expression} -> Maybe Text
expression) (\s :: SubSlotSetting
s@SubSlotSetting' {} Maybe Text
a -> SubSlotSetting
s {$sel:expression:SubSlotSetting' :: Maybe Text
expression = Maybe Text
a} :: SubSlotSetting)

-- | Specifications for the constituent sub slots of a composite slot.
subSlotSetting_slotSpecifications :: Lens.Lens' SubSlotSetting (Prelude.Maybe (Prelude.HashMap Prelude.Text Specifications))
subSlotSetting_slotSpecifications :: Lens' SubSlotSetting (Maybe (HashMap Text Specifications))
subSlotSetting_slotSpecifications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubSlotSetting' {Maybe (HashMap Text Specifications)
slotSpecifications :: Maybe (HashMap Text Specifications)
$sel:slotSpecifications:SubSlotSetting' :: SubSlotSetting -> Maybe (HashMap Text Specifications)
slotSpecifications} -> Maybe (HashMap Text Specifications)
slotSpecifications) (\s :: SubSlotSetting
s@SubSlotSetting' {} Maybe (HashMap Text Specifications)
a -> SubSlotSetting
s {$sel:slotSpecifications:SubSlotSetting' :: Maybe (HashMap Text Specifications)
slotSpecifications = Maybe (HashMap Text Specifications)
a} :: SubSlotSetting) 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 SubSlotSetting where
  parseJSON :: Value -> Parser SubSlotSetting
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SubSlotSetting"
      ( \Object
x ->
          Maybe Text -> Maybe (HashMap Text Specifications) -> SubSlotSetting
SubSlotSetting'
            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
"expression")
            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
"slotSpecifications"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable SubSlotSetting where
  hashWithSalt :: Int -> SubSlotSetting -> Int
hashWithSalt Int
_salt SubSlotSetting' {Maybe Text
Maybe (HashMap Text Specifications)
slotSpecifications :: Maybe (HashMap Text Specifications)
expression :: Maybe Text
$sel:slotSpecifications:SubSlotSetting' :: SubSlotSetting -> Maybe (HashMap Text Specifications)
$sel:expression:SubSlotSetting' :: SubSlotSetting -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Specifications)
slotSpecifications

instance Prelude.NFData SubSlotSetting where
  rnf :: SubSlotSetting -> ()
rnf SubSlotSetting' {Maybe Text
Maybe (HashMap Text Specifications)
slotSpecifications :: Maybe (HashMap Text Specifications)
expression :: Maybe Text
$sel:slotSpecifications:SubSlotSetting' :: SubSlotSetting -> Maybe (HashMap Text Specifications)
$sel:expression:SubSlotSetting' :: SubSlotSetting -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Specifications)
slotSpecifications

instance Data.ToJSON SubSlotSetting where
  toJSON :: SubSlotSetting -> Value
toJSON SubSlotSetting' {Maybe Text
Maybe (HashMap Text Specifications)
slotSpecifications :: Maybe (HashMap Text Specifications)
expression :: Maybe Text
$sel:slotSpecifications:SubSlotSetting' :: SubSlotSetting -> Maybe (HashMap Text Specifications)
$sel:expression:SubSlotSetting' :: SubSlotSetting -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"expression" 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
expression,
            (Key
"slotSpecifications" 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 (HashMap Text Specifications)
slotSpecifications
          ]
      )