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

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

-- | The unique custom vocabulary item from the custom vocabulary list.
--
-- /See:/ 'newCustomVocabularyItem' smart constructor.
data CustomVocabularyItem = CustomVocabularyItem'
  { -- | The display as value for the custom vocabulary item from the custom
    -- vocabulary list.
    CustomVocabularyItem -> Maybe Text
displayAs :: Prelude.Maybe Prelude.Text,
    -- | The weight assigned for the custom vocabulary item from the custom
    -- vocabulary list.
    CustomVocabularyItem -> Maybe Natural
weight :: Prelude.Maybe Prelude.Natural,
    -- | The unique item identifer for the custom vocabulary item from the custom
    -- vocabulary list.
    CustomVocabularyItem -> Text
itemId :: Prelude.Text,
    -- | The unique phrase for the custom vocabulary item from the custom
    -- vocabulary list.
    CustomVocabularyItem -> Text
phrase :: Prelude.Text
  }
  deriving (CustomVocabularyItem -> CustomVocabularyItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomVocabularyItem -> CustomVocabularyItem -> Bool
$c/= :: CustomVocabularyItem -> CustomVocabularyItem -> Bool
== :: CustomVocabularyItem -> CustomVocabularyItem -> Bool
$c== :: CustomVocabularyItem -> CustomVocabularyItem -> Bool
Prelude.Eq, ReadPrec [CustomVocabularyItem]
ReadPrec CustomVocabularyItem
Int -> ReadS CustomVocabularyItem
ReadS [CustomVocabularyItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomVocabularyItem]
$creadListPrec :: ReadPrec [CustomVocabularyItem]
readPrec :: ReadPrec CustomVocabularyItem
$creadPrec :: ReadPrec CustomVocabularyItem
readList :: ReadS [CustomVocabularyItem]
$creadList :: ReadS [CustomVocabularyItem]
readsPrec :: Int -> ReadS CustomVocabularyItem
$creadsPrec :: Int -> ReadS CustomVocabularyItem
Prelude.Read, Int -> CustomVocabularyItem -> ShowS
[CustomVocabularyItem] -> ShowS
CustomVocabularyItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomVocabularyItem] -> ShowS
$cshowList :: [CustomVocabularyItem] -> ShowS
show :: CustomVocabularyItem -> String
$cshow :: CustomVocabularyItem -> String
showsPrec :: Int -> CustomVocabularyItem -> ShowS
$cshowsPrec :: Int -> CustomVocabularyItem -> ShowS
Prelude.Show, forall x. Rep CustomVocabularyItem x -> CustomVocabularyItem
forall x. CustomVocabularyItem -> Rep CustomVocabularyItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomVocabularyItem x -> CustomVocabularyItem
$cfrom :: forall x. CustomVocabularyItem -> Rep CustomVocabularyItem x
Prelude.Generic)

-- |
-- Create a value of 'CustomVocabularyItem' 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:
--
-- 'displayAs', 'customVocabularyItem_displayAs' - The display as value for the custom vocabulary item from the custom
-- vocabulary list.
--
-- 'weight', 'customVocabularyItem_weight' - The weight assigned for the custom vocabulary item from the custom
-- vocabulary list.
--
-- 'itemId', 'customVocabularyItem_itemId' - The unique item identifer for the custom vocabulary item from the custom
-- vocabulary list.
--
-- 'phrase', 'customVocabularyItem_phrase' - The unique phrase for the custom vocabulary item from the custom
-- vocabulary list.
newCustomVocabularyItem ::
  -- | 'itemId'
  Prelude.Text ->
  -- | 'phrase'
  Prelude.Text ->
  CustomVocabularyItem
newCustomVocabularyItem :: Text -> Text -> CustomVocabularyItem
newCustomVocabularyItem Text
pItemId_ Text
pPhrase_ =
  CustomVocabularyItem'
    { $sel:displayAs:CustomVocabularyItem' :: Maybe Text
displayAs = forall a. Maybe a
Prelude.Nothing,
      $sel:weight:CustomVocabularyItem' :: Maybe Natural
weight = forall a. Maybe a
Prelude.Nothing,
      $sel:itemId:CustomVocabularyItem' :: Text
itemId = Text
pItemId_,
      $sel:phrase:CustomVocabularyItem' :: Text
phrase = Text
pPhrase_
    }

-- | The display as value for the custom vocabulary item from the custom
-- vocabulary list.
customVocabularyItem_displayAs :: Lens.Lens' CustomVocabularyItem (Prelude.Maybe Prelude.Text)
customVocabularyItem_displayAs :: Lens' CustomVocabularyItem (Maybe Text)
customVocabularyItem_displayAs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomVocabularyItem' {Maybe Text
displayAs :: Maybe Text
$sel:displayAs:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Text
displayAs} -> Maybe Text
displayAs) (\s :: CustomVocabularyItem
s@CustomVocabularyItem' {} Maybe Text
a -> CustomVocabularyItem
s {$sel:displayAs:CustomVocabularyItem' :: Maybe Text
displayAs = Maybe Text
a} :: CustomVocabularyItem)

-- | The weight assigned for the custom vocabulary item from the custom
-- vocabulary list.
customVocabularyItem_weight :: Lens.Lens' CustomVocabularyItem (Prelude.Maybe Prelude.Natural)
customVocabularyItem_weight :: Lens' CustomVocabularyItem (Maybe Natural)
customVocabularyItem_weight = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomVocabularyItem' {Maybe Natural
weight :: Maybe Natural
$sel:weight:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Natural
weight} -> Maybe Natural
weight) (\s :: CustomVocabularyItem
s@CustomVocabularyItem' {} Maybe Natural
a -> CustomVocabularyItem
s {$sel:weight:CustomVocabularyItem' :: Maybe Natural
weight = Maybe Natural
a} :: CustomVocabularyItem)

-- | The unique item identifer for the custom vocabulary item from the custom
-- vocabulary list.
customVocabularyItem_itemId :: Lens.Lens' CustomVocabularyItem Prelude.Text
customVocabularyItem_itemId :: Lens' CustomVocabularyItem Text
customVocabularyItem_itemId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomVocabularyItem' {Text
itemId :: Text
$sel:itemId:CustomVocabularyItem' :: CustomVocabularyItem -> Text
itemId} -> Text
itemId) (\s :: CustomVocabularyItem
s@CustomVocabularyItem' {} Text
a -> CustomVocabularyItem
s {$sel:itemId:CustomVocabularyItem' :: Text
itemId = Text
a} :: CustomVocabularyItem)

-- | The unique phrase for the custom vocabulary item from the custom
-- vocabulary list.
customVocabularyItem_phrase :: Lens.Lens' CustomVocabularyItem Prelude.Text
customVocabularyItem_phrase :: Lens' CustomVocabularyItem Text
customVocabularyItem_phrase = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomVocabularyItem' {Text
phrase :: Text
$sel:phrase:CustomVocabularyItem' :: CustomVocabularyItem -> Text
phrase} -> Text
phrase) (\s :: CustomVocabularyItem
s@CustomVocabularyItem' {} Text
a -> CustomVocabularyItem
s {$sel:phrase:CustomVocabularyItem' :: Text
phrase = Text
a} :: CustomVocabularyItem)

instance Data.FromJSON CustomVocabularyItem where
  parseJSON :: Value -> Parser CustomVocabularyItem
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomVocabularyItem"
      ( \Object
x ->
          Maybe Text -> Maybe Natural -> Text -> Text -> CustomVocabularyItem
CustomVocabularyItem'
            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
"displayAs")
            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
"weight")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"itemId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"phrase")
      )

instance Prelude.Hashable CustomVocabularyItem where
  hashWithSalt :: Int -> CustomVocabularyItem -> Int
hashWithSalt Int
_salt CustomVocabularyItem' {Maybe Natural
Maybe Text
Text
phrase :: Text
itemId :: Text
weight :: Maybe Natural
displayAs :: Maybe Text
$sel:phrase:CustomVocabularyItem' :: CustomVocabularyItem -> Text
$sel:itemId:CustomVocabularyItem' :: CustomVocabularyItem -> Text
$sel:weight:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Natural
$sel:displayAs:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
displayAs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
weight
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
itemId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
phrase

instance Prelude.NFData CustomVocabularyItem where
  rnf :: CustomVocabularyItem -> ()
rnf CustomVocabularyItem' {Maybe Natural
Maybe Text
Text
phrase :: Text
itemId :: Text
weight :: Maybe Natural
displayAs :: Maybe Text
$sel:phrase:CustomVocabularyItem' :: CustomVocabularyItem -> Text
$sel:itemId:CustomVocabularyItem' :: CustomVocabularyItem -> Text
$sel:weight:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Natural
$sel:displayAs:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
displayAs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
weight
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
itemId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
phrase

instance Data.ToJSON CustomVocabularyItem where
  toJSON :: CustomVocabularyItem -> Value
toJSON CustomVocabularyItem' {Maybe Natural
Maybe Text
Text
phrase :: Text
itemId :: Text
weight :: Maybe Natural
displayAs :: Maybe Text
$sel:phrase:CustomVocabularyItem' :: CustomVocabularyItem -> Text
$sel:itemId:CustomVocabularyItem' :: CustomVocabularyItem -> Text
$sel:weight:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Natural
$sel:displayAs:CustomVocabularyItem' :: CustomVocabularyItem -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"displayAs" 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
displayAs,
            (Key
"weight" 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 Natural
weight,
            forall a. a -> Maybe a
Prelude.Just (Key
"itemId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
itemId),
            forall a. a -> Maybe a
Prelude.Just (Key
"phrase" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
phrase)
          ]
      )