{-# 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.Polly.Types.Lexicon
-- 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.Polly.Types.Lexicon 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

-- | Provides lexicon name and lexicon content in string format. For more
-- information, see
-- <https://www.w3.org/TR/pronunciation-lexicon/ Pronunciation Lexicon Specification (PLS) Version 1.0>.
--
-- /See:/ 'newLexicon' smart constructor.
data Lexicon = Lexicon'
  { -- | Lexicon content in string format. The content of a lexicon must be in
    -- PLS format.
    Lexicon -> Maybe (Sensitive Text)
content :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | Name of the lexicon.
    Lexicon -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Lexicon -> Lexicon -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Lexicon -> Lexicon -> Bool
$c/= :: Lexicon -> Lexicon -> Bool
== :: Lexicon -> Lexicon -> Bool
$c== :: Lexicon -> Lexicon -> Bool
Prelude.Eq, Int -> Lexicon -> ShowS
[Lexicon] -> ShowS
Lexicon -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Lexicon] -> ShowS
$cshowList :: [Lexicon] -> ShowS
show :: Lexicon -> String
$cshow :: Lexicon -> String
showsPrec :: Int -> Lexicon -> ShowS
$cshowsPrec :: Int -> Lexicon -> ShowS
Prelude.Show, forall x. Rep Lexicon x -> Lexicon
forall x. Lexicon -> Rep Lexicon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Lexicon x -> Lexicon
$cfrom :: forall x. Lexicon -> Rep Lexicon x
Prelude.Generic)

-- |
-- Create a value of 'Lexicon' 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:
--
-- 'content', 'lexicon_content' - Lexicon content in string format. The content of a lexicon must be in
-- PLS format.
--
-- 'name', 'lexicon_name' - Name of the lexicon.
newLexicon ::
  Lexicon
newLexicon :: Lexicon
newLexicon =
  Lexicon'
    { $sel:content:Lexicon' :: Maybe (Sensitive Text)
content = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Lexicon' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | Lexicon content in string format. The content of a lexicon must be in
-- PLS format.
lexicon_content :: Lens.Lens' Lexicon (Prelude.Maybe Prelude.Text)
lexicon_content :: Lens' Lexicon (Maybe Text)
lexicon_content = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Lexicon' {Maybe (Sensitive Text)
content :: Maybe (Sensitive Text)
$sel:content:Lexicon' :: Lexicon -> Maybe (Sensitive Text)
content} -> Maybe (Sensitive Text)
content) (\s :: Lexicon
s@Lexicon' {} Maybe (Sensitive Text)
a -> Lexicon
s {$sel:content:Lexicon' :: Maybe (Sensitive Text)
content = Maybe (Sensitive Text)
a} :: Lexicon) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | Name of the lexicon.
lexicon_name :: Lens.Lens' Lexicon (Prelude.Maybe Prelude.Text)
lexicon_name :: Lens' Lexicon (Maybe Text)
lexicon_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Lexicon' {Maybe Text
name :: Maybe Text
$sel:name:Lexicon' :: Lexicon -> Maybe Text
name} -> Maybe Text
name) (\s :: Lexicon
s@Lexicon' {} Maybe Text
a -> Lexicon
s {$sel:name:Lexicon' :: Maybe Text
name = Maybe Text
a} :: Lexicon)

instance Data.FromJSON Lexicon where
  parseJSON :: Value -> Parser Lexicon
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Lexicon"
      ( \Object
x ->
          Maybe (Sensitive Text) -> Maybe Text -> Lexicon
Lexicon'
            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
"Content")
            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
"Name")
      )

instance Prelude.Hashable Lexicon where
  hashWithSalt :: Int -> Lexicon -> Int
hashWithSalt Int
_salt Lexicon' {Maybe Text
Maybe (Sensitive Text)
name :: Maybe Text
content :: Maybe (Sensitive Text)
$sel:name:Lexicon' :: Lexicon -> Maybe Text
$sel:content:Lexicon' :: Lexicon -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
content
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData Lexicon where
  rnf :: Lexicon -> ()
rnf Lexicon' {Maybe Text
Maybe (Sensitive Text)
name :: Maybe Text
content :: Maybe (Sensitive Text)
$sel:name:Lexicon' :: Lexicon -> Maybe Text
$sel:content:Lexicon' :: Lexicon -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
content seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name