{-# 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.Wisdom.Types.DocumentText
-- 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.Wisdom.Types.DocumentText 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
import Amazonka.Wisdom.Types.Highlight

-- | The text of the document.
--
-- /See:/ 'newDocumentText' smart constructor.
data DocumentText = DocumentText'
  { -- | Highlights in the document text.
    DocumentText -> Maybe [Highlight]
highlights :: Prelude.Maybe [Highlight],
    -- | Text in the document.
    DocumentText -> Maybe (Sensitive Text)
text :: Prelude.Maybe (Data.Sensitive Prelude.Text)
  }
  deriving (DocumentText -> DocumentText -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentText -> DocumentText -> Bool
$c/= :: DocumentText -> DocumentText -> Bool
== :: DocumentText -> DocumentText -> Bool
$c== :: DocumentText -> DocumentText -> Bool
Prelude.Eq, Int -> DocumentText -> ShowS
[DocumentText] -> ShowS
DocumentText -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentText] -> ShowS
$cshowList :: [DocumentText] -> ShowS
show :: DocumentText -> String
$cshow :: DocumentText -> String
showsPrec :: Int -> DocumentText -> ShowS
$cshowsPrec :: Int -> DocumentText -> ShowS
Prelude.Show, forall x. Rep DocumentText x -> DocumentText
forall x. DocumentText -> Rep DocumentText x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentText x -> DocumentText
$cfrom :: forall x. DocumentText -> Rep DocumentText x
Prelude.Generic)

-- |
-- Create a value of 'DocumentText' 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:
--
-- 'highlights', 'documentText_highlights' - Highlights in the document text.
--
-- 'text', 'documentText_text' - Text in the document.
newDocumentText ::
  DocumentText
newDocumentText :: DocumentText
newDocumentText =
  DocumentText'
    { $sel:highlights:DocumentText' :: Maybe [Highlight]
highlights = forall a. Maybe a
Prelude.Nothing,
      $sel:text:DocumentText' :: Maybe (Sensitive Text)
text = forall a. Maybe a
Prelude.Nothing
    }

-- | Highlights in the document text.
documentText_highlights :: Lens.Lens' DocumentText (Prelude.Maybe [Highlight])
documentText_highlights :: Lens' DocumentText (Maybe [Highlight])
documentText_highlights = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentText' {Maybe [Highlight]
highlights :: Maybe [Highlight]
$sel:highlights:DocumentText' :: DocumentText -> Maybe [Highlight]
highlights} -> Maybe [Highlight]
highlights) (\s :: DocumentText
s@DocumentText' {} Maybe [Highlight]
a -> DocumentText
s {$sel:highlights:DocumentText' :: Maybe [Highlight]
highlights = Maybe [Highlight]
a} :: DocumentText) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Text in the document.
documentText_text :: Lens.Lens' DocumentText (Prelude.Maybe Prelude.Text)
documentText_text :: Lens' DocumentText (Maybe Text)
documentText_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentText' {Maybe (Sensitive Text)
text :: Maybe (Sensitive Text)
$sel:text:DocumentText' :: DocumentText -> Maybe (Sensitive Text)
text} -> Maybe (Sensitive Text)
text) (\s :: DocumentText
s@DocumentText' {} Maybe (Sensitive Text)
a -> DocumentText
s {$sel:text:DocumentText' :: Maybe (Sensitive Text)
text = Maybe (Sensitive Text)
a} :: DocumentText) 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

instance Data.FromJSON DocumentText where
  parseJSON :: Value -> Parser DocumentText
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentText"
      ( \Object
x ->
          Maybe [Highlight] -> Maybe (Sensitive Text) -> DocumentText
DocumentText'
            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
"highlights" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"text")
      )

instance Prelude.Hashable DocumentText where
  hashWithSalt :: Int -> DocumentText -> Int
hashWithSalt Int
_salt DocumentText' {Maybe [Highlight]
Maybe (Sensitive Text)
text :: Maybe (Sensitive Text)
highlights :: Maybe [Highlight]
$sel:text:DocumentText' :: DocumentText -> Maybe (Sensitive Text)
$sel:highlights:DocumentText' :: DocumentText -> Maybe [Highlight]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Highlight]
highlights
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
text

instance Prelude.NFData DocumentText where
  rnf :: DocumentText -> ()
rnf DocumentText' {Maybe [Highlight]
Maybe (Sensitive Text)
text :: Maybe (Sensitive Text)
highlights :: Maybe [Highlight]
$sel:text:DocumentText' :: DocumentText -> Maybe (Sensitive Text)
$sel:highlights:DocumentText' :: DocumentText -> Maybe [Highlight]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Highlight]
highlights
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
text