{-# 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.Connect.Types.StringCondition
-- 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.Connect.Types.StringCondition where

import Amazonka.Connect.Types.StringComparisonType
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

-- | A leaf node condition which can be used to specify a string condition.
--
-- The currently supported value for @FieldName@: @name@
--
-- /See:/ 'newStringCondition' smart constructor.
data StringCondition = StringCondition'
  { -- | The type of comparison to be made when evaluating the string condition.
    StringCondition -> Maybe StringComparisonType
comparisonType :: Prelude.Maybe StringComparisonType,
    -- | The name of the field in the string condition.
    StringCondition -> Maybe Text
fieldName :: Prelude.Maybe Prelude.Text,
    -- | The value of the string.
    StringCondition -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (StringCondition -> StringCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StringCondition -> StringCondition -> Bool
$c/= :: StringCondition -> StringCondition -> Bool
== :: StringCondition -> StringCondition -> Bool
$c== :: StringCondition -> StringCondition -> Bool
Prelude.Eq, ReadPrec [StringCondition]
ReadPrec StringCondition
Int -> ReadS StringCondition
ReadS [StringCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StringCondition]
$creadListPrec :: ReadPrec [StringCondition]
readPrec :: ReadPrec StringCondition
$creadPrec :: ReadPrec StringCondition
readList :: ReadS [StringCondition]
$creadList :: ReadS [StringCondition]
readsPrec :: Int -> ReadS StringCondition
$creadsPrec :: Int -> ReadS StringCondition
Prelude.Read, Int -> StringCondition -> ShowS
[StringCondition] -> ShowS
StringCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StringCondition] -> ShowS
$cshowList :: [StringCondition] -> ShowS
show :: StringCondition -> String
$cshow :: StringCondition -> String
showsPrec :: Int -> StringCondition -> ShowS
$cshowsPrec :: Int -> StringCondition -> ShowS
Prelude.Show, forall x. Rep StringCondition x -> StringCondition
forall x. StringCondition -> Rep StringCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StringCondition x -> StringCondition
$cfrom :: forall x. StringCondition -> Rep StringCondition x
Prelude.Generic)

-- |
-- Create a value of 'StringCondition' 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:
--
-- 'comparisonType', 'stringCondition_comparisonType' - The type of comparison to be made when evaluating the string condition.
--
-- 'fieldName', 'stringCondition_fieldName' - The name of the field in the string condition.
--
-- 'value', 'stringCondition_value' - The value of the string.
newStringCondition ::
  StringCondition
newStringCondition :: StringCondition
newStringCondition =
  StringCondition'
    { $sel:comparisonType:StringCondition' :: Maybe StringComparisonType
comparisonType = forall a. Maybe a
Prelude.Nothing,
      $sel:fieldName:StringCondition' :: Maybe Text
fieldName = forall a. Maybe a
Prelude.Nothing,
      $sel:value:StringCondition' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of comparison to be made when evaluating the string condition.
stringCondition_comparisonType :: Lens.Lens' StringCondition (Prelude.Maybe StringComparisonType)
stringCondition_comparisonType :: Lens' StringCondition (Maybe StringComparisonType)
stringCondition_comparisonType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringCondition' {Maybe StringComparisonType
comparisonType :: Maybe StringComparisonType
$sel:comparisonType:StringCondition' :: StringCondition -> Maybe StringComparisonType
comparisonType} -> Maybe StringComparisonType
comparisonType) (\s :: StringCondition
s@StringCondition' {} Maybe StringComparisonType
a -> StringCondition
s {$sel:comparisonType:StringCondition' :: Maybe StringComparisonType
comparisonType = Maybe StringComparisonType
a} :: StringCondition)

-- | The name of the field in the string condition.
stringCondition_fieldName :: Lens.Lens' StringCondition (Prelude.Maybe Prelude.Text)
stringCondition_fieldName :: Lens' StringCondition (Maybe Text)
stringCondition_fieldName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringCondition' {Maybe Text
fieldName :: Maybe Text
$sel:fieldName:StringCondition' :: StringCondition -> Maybe Text
fieldName} -> Maybe Text
fieldName) (\s :: StringCondition
s@StringCondition' {} Maybe Text
a -> StringCondition
s {$sel:fieldName:StringCondition' :: Maybe Text
fieldName = Maybe Text
a} :: StringCondition)

-- | The value of the string.
stringCondition_value :: Lens.Lens' StringCondition (Prelude.Maybe Prelude.Text)
stringCondition_value :: Lens' StringCondition (Maybe Text)
stringCondition_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringCondition' {Maybe Text
value :: Maybe Text
$sel:value:StringCondition' :: StringCondition -> Maybe Text
value} -> Maybe Text
value) (\s :: StringCondition
s@StringCondition' {} Maybe Text
a -> StringCondition
s {$sel:value:StringCondition' :: Maybe Text
value = Maybe Text
a} :: StringCondition)

instance Prelude.Hashable StringCondition where
  hashWithSalt :: Int -> StringCondition -> Int
hashWithSalt Int
_salt StringCondition' {Maybe Text
Maybe StringComparisonType
value :: Maybe Text
fieldName :: Maybe Text
comparisonType :: Maybe StringComparisonType
$sel:value:StringCondition' :: StringCondition -> Maybe Text
$sel:fieldName:StringCondition' :: StringCondition -> Maybe Text
$sel:comparisonType:StringCondition' :: StringCondition -> Maybe StringComparisonType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StringComparisonType
comparisonType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fieldName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData StringCondition where
  rnf :: StringCondition -> ()
rnf StringCondition' {Maybe Text
Maybe StringComparisonType
value :: Maybe Text
fieldName :: Maybe Text
comparisonType :: Maybe StringComparisonType
$sel:value:StringCondition' :: StringCondition -> Maybe Text
$sel:fieldName:StringCondition' :: StringCondition -> Maybe Text
$sel:comparisonType:StringCondition' :: StringCondition -> Maybe StringComparisonType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StringComparisonType
comparisonType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fieldName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON StringCondition where
  toJSON :: StringCondition -> Value
toJSON StringCondition' {Maybe Text
Maybe StringComparisonType
value :: Maybe Text
fieldName :: Maybe Text
comparisonType :: Maybe StringComparisonType
$sel:value:StringCondition' :: StringCondition -> Maybe Text
$sel:fieldName:StringCondition' :: StringCondition -> Maybe Text
$sel:comparisonType:StringCondition' :: StringCondition -> Maybe StringComparisonType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ComparisonType" 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 StringComparisonType
comparisonType,
            (Key
"FieldName" 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
fieldName,
            (Key
"Value" 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
value
          ]
      )