{-# 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.SlotTypeConfiguration
-- 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.SlotTypeConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexModels.Types.SlotTypeRegexConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Provides configuration information for a slot type.
--
-- /See:/ 'newSlotTypeConfiguration' smart constructor.
data SlotTypeConfiguration = SlotTypeConfiguration'
  { -- | A regular expression used to validate the value of a slot.
    SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
regexConfiguration :: Prelude.Maybe SlotTypeRegexConfiguration
  }
  deriving (SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
$c/= :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
== :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
$c== :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
Prelude.Eq, ReadPrec [SlotTypeConfiguration]
ReadPrec SlotTypeConfiguration
Int -> ReadS SlotTypeConfiguration
ReadS [SlotTypeConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotTypeConfiguration]
$creadListPrec :: ReadPrec [SlotTypeConfiguration]
readPrec :: ReadPrec SlotTypeConfiguration
$creadPrec :: ReadPrec SlotTypeConfiguration
readList :: ReadS [SlotTypeConfiguration]
$creadList :: ReadS [SlotTypeConfiguration]
readsPrec :: Int -> ReadS SlotTypeConfiguration
$creadsPrec :: Int -> ReadS SlotTypeConfiguration
Prelude.Read, Int -> SlotTypeConfiguration -> ShowS
[SlotTypeConfiguration] -> ShowS
SlotTypeConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotTypeConfiguration] -> ShowS
$cshowList :: [SlotTypeConfiguration] -> ShowS
show :: SlotTypeConfiguration -> String
$cshow :: SlotTypeConfiguration -> String
showsPrec :: Int -> SlotTypeConfiguration -> ShowS
$cshowsPrec :: Int -> SlotTypeConfiguration -> ShowS
Prelude.Show, forall x. Rep SlotTypeConfiguration x -> SlotTypeConfiguration
forall x. SlotTypeConfiguration -> Rep SlotTypeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotTypeConfiguration x -> SlotTypeConfiguration
$cfrom :: forall x. SlotTypeConfiguration -> Rep SlotTypeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SlotTypeConfiguration' 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:
--
-- 'regexConfiguration', 'slotTypeConfiguration_regexConfiguration' - A regular expression used to validate the value of a slot.
newSlotTypeConfiguration ::
  SlotTypeConfiguration
newSlotTypeConfiguration :: SlotTypeConfiguration
newSlotTypeConfiguration =
  SlotTypeConfiguration'
    { $sel:regexConfiguration:SlotTypeConfiguration' :: Maybe SlotTypeRegexConfiguration
regexConfiguration =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A regular expression used to validate the value of a slot.
slotTypeConfiguration_regexConfiguration :: Lens.Lens' SlotTypeConfiguration (Prelude.Maybe SlotTypeRegexConfiguration)
slotTypeConfiguration_regexConfiguration :: Lens' SlotTypeConfiguration (Maybe SlotTypeRegexConfiguration)
slotTypeConfiguration_regexConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeConfiguration' {Maybe SlotTypeRegexConfiguration
regexConfiguration :: Maybe SlotTypeRegexConfiguration
$sel:regexConfiguration:SlotTypeConfiguration' :: SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
regexConfiguration} -> Maybe SlotTypeRegexConfiguration
regexConfiguration) (\s :: SlotTypeConfiguration
s@SlotTypeConfiguration' {} Maybe SlotTypeRegexConfiguration
a -> SlotTypeConfiguration
s {$sel:regexConfiguration:SlotTypeConfiguration' :: Maybe SlotTypeRegexConfiguration
regexConfiguration = Maybe SlotTypeRegexConfiguration
a} :: SlotTypeConfiguration)

instance Data.FromJSON SlotTypeConfiguration where
  parseJSON :: Value -> Parser SlotTypeConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SlotTypeConfiguration"
      ( \Object
x ->
          Maybe SlotTypeRegexConfiguration -> SlotTypeConfiguration
SlotTypeConfiguration'
            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
"regexConfiguration")
      )

instance Prelude.Hashable SlotTypeConfiguration where
  hashWithSalt :: Int -> SlotTypeConfiguration -> Int
hashWithSalt Int
_salt SlotTypeConfiguration' {Maybe SlotTypeRegexConfiguration
regexConfiguration :: Maybe SlotTypeRegexConfiguration
$sel:regexConfiguration:SlotTypeConfiguration' :: SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SlotTypeRegexConfiguration
regexConfiguration

instance Prelude.NFData SlotTypeConfiguration where
  rnf :: SlotTypeConfiguration -> ()
rnf SlotTypeConfiguration' {Maybe SlotTypeRegexConfiguration
regexConfiguration :: Maybe SlotTypeRegexConfiguration
$sel:regexConfiguration:SlotTypeConfiguration' :: SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SlotTypeRegexConfiguration
regexConfiguration

instance Data.ToJSON SlotTypeConfiguration where
  toJSON :: SlotTypeConfiguration -> Value
toJSON SlotTypeConfiguration' {Maybe SlotTypeRegexConfiguration
regexConfiguration :: Maybe SlotTypeRegexConfiguration
$sel:regexConfiguration:SlotTypeConfiguration' :: SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"regexConfiguration" 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 SlotTypeRegexConfiguration
regexConfiguration
          ]
      )