{-# 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.Translate.Types.Term
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Translate.Types.Term where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The term being translated by the custom terminology.
--
-- /See:/ 'newTerm' smart constructor.
data Term = Term'
  { -- | The target text of the term being translated by the custom terminology.
    Term -> Maybe Text
targetText :: Prelude.Maybe Prelude.Text,
    -- | The source text of the term being translated by the custom terminology.
    Term -> Maybe Text
sourceText :: Prelude.Maybe Prelude.Text
  }
  deriving (Term -> Term -> Bool
(Term -> Term -> Bool) -> (Term -> Term -> Bool) -> Eq Term
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Term -> Term -> Bool
$c/= :: Term -> Term -> Bool
== :: Term -> Term -> Bool
$c== :: Term -> Term -> Bool
Prelude.Eq, ReadPrec [Term]
ReadPrec Term
Int -> ReadS Term
ReadS [Term]
(Int -> ReadS Term)
-> ReadS [Term] -> ReadPrec Term -> ReadPrec [Term] -> Read Term
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Term]
$creadListPrec :: ReadPrec [Term]
readPrec :: ReadPrec Term
$creadPrec :: ReadPrec Term
readList :: ReadS [Term]
$creadList :: ReadS [Term]
readsPrec :: Int -> ReadS Term
$creadsPrec :: Int -> ReadS Term
Prelude.Read, Int -> Term -> ShowS
[Term] -> ShowS
Term -> String
(Int -> Term -> ShowS)
-> (Term -> String) -> ([Term] -> ShowS) -> Show Term
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Term] -> ShowS
$cshowList :: [Term] -> ShowS
show :: Term -> String
$cshow :: Term -> String
showsPrec :: Int -> Term -> ShowS
$cshowsPrec :: Int -> Term -> ShowS
Prelude.Show, (forall x. Term -> Rep Term x)
-> (forall x. Rep Term x -> Term) -> Generic Term
forall x. Rep Term x -> Term
forall x. Term -> Rep Term x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Term x -> Term
$cfrom :: forall x. Term -> Rep Term x
Prelude.Generic)

-- |
-- Create a value of 'Term' 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:
--
-- 'targetText', 'term_targetText' - The target text of the term being translated by the custom terminology.
--
-- 'sourceText', 'term_sourceText' - The source text of the term being translated by the custom terminology.
newTerm ::
  Term
newTerm :: Term
newTerm =
  Term' :: Maybe Text -> Maybe Text -> Term
Term'
    { $sel:targetText:Term' :: Maybe Text
targetText = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceText:Term' :: Maybe Text
sourceText = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The target text of the term being translated by the custom terminology.
term_targetText :: Lens.Lens' Term (Prelude.Maybe Prelude.Text)
term_targetText :: (Maybe Text -> f (Maybe Text)) -> Term -> f Term
term_targetText = (Term -> Maybe Text)
-> (Term -> Maybe Text -> Term)
-> Lens Term Term (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Term' {Maybe Text
targetText :: Maybe Text
$sel:targetText:Term' :: Term -> Maybe Text
targetText} -> Maybe Text
targetText) (\s :: Term
s@Term' {} Maybe Text
a -> Term
s {$sel:targetText:Term' :: Maybe Text
targetText = Maybe Text
a} :: Term)

-- | The source text of the term being translated by the custom terminology.
term_sourceText :: Lens.Lens' Term (Prelude.Maybe Prelude.Text)
term_sourceText :: (Maybe Text -> f (Maybe Text)) -> Term -> f Term
term_sourceText = (Term -> Maybe Text)
-> (Term -> Maybe Text -> Term)
-> Lens Term Term (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Term' {Maybe Text
sourceText :: Maybe Text
$sel:sourceText:Term' :: Term -> Maybe Text
sourceText} -> Maybe Text
sourceText) (\s :: Term
s@Term' {} Maybe Text
a -> Term
s {$sel:sourceText:Term' :: Maybe Text
sourceText = Maybe Text
a} :: Term)

instance Core.FromJSON Term where
  parseJSON :: Value -> Parser Term
parseJSON =
    String -> (Object -> Parser Term) -> Value -> Parser Term
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Term"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Term
Term'
            (Maybe Text -> Maybe Text -> Term)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Term)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetText")
            Parser (Maybe Text -> Term) -> Parser (Maybe Text) -> Parser Term
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SourceText")
      )

instance Prelude.Hashable Term

instance Prelude.NFData Term