{-# 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-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.Wisdom.Types.DocumentText where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Wisdom.Types.Highlight

-- | The text of the document.
--
-- /See:/ 'newDocumentText' smart constructor.
data DocumentText = DocumentText'
  { -- | Text in the document.
    DocumentText -> Maybe (Sensitive Text)
text :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | Highlights in the document text.
    DocumentText -> Maybe [Highlight]
highlights :: Prelude.Maybe [Highlight]
  }
  deriving (DocumentText -> DocumentText -> Bool
(DocumentText -> DocumentText -> Bool)
-> (DocumentText -> DocumentText -> Bool) -> Eq DocumentText
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
(Int -> DocumentText -> ShowS)
-> (DocumentText -> String)
-> ([DocumentText] -> ShowS)
-> Show DocumentText
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. DocumentText -> Rep DocumentText x)
-> (forall x. Rep DocumentText x -> DocumentText)
-> Generic DocumentText
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:
--
-- 'text', 'documentText_text' - Text in the document.
--
-- 'highlights', 'documentText_highlights' - Highlights in the document text.
newDocumentText ::
  DocumentText
newDocumentText :: DocumentText
newDocumentText =
  DocumentText' :: Maybe (Sensitive Text) -> Maybe [Highlight] -> DocumentText
DocumentText'
    { $sel:text:DocumentText' :: Maybe (Sensitive Text)
text = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:highlights:DocumentText' :: Maybe [Highlight]
highlights = Maybe [Highlight]
forall a. Maybe a
Prelude.Nothing
    }

-- | Text in the document.
documentText_text :: Lens.Lens' DocumentText (Prelude.Maybe Prelude.Text)
documentText_text :: (Maybe Text -> f (Maybe Text)) -> DocumentText -> f DocumentText
documentText_text = (DocumentText -> Maybe (Sensitive Text))
-> (DocumentText -> Maybe (Sensitive Text) -> DocumentText)
-> Lens
     DocumentText
     DocumentText
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DocumentText -> f DocumentText)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DocumentText
-> f DocumentText
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | Highlights in the document text.
documentText_highlights :: Lens.Lens' DocumentText (Prelude.Maybe [Highlight])
documentText_highlights :: (Maybe [Highlight] -> f (Maybe [Highlight]))
-> DocumentText -> f DocumentText
documentText_highlights = (DocumentText -> Maybe [Highlight])
-> (DocumentText -> Maybe [Highlight] -> DocumentText)
-> Lens
     DocumentText DocumentText (Maybe [Highlight]) (Maybe [Highlight])
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) ((Maybe [Highlight] -> f (Maybe [Highlight]))
 -> DocumentText -> f DocumentText)
-> ((Maybe [Highlight] -> f (Maybe [Highlight]))
    -> Maybe [Highlight] -> f (Maybe [Highlight]))
-> (Maybe [Highlight] -> f (Maybe [Highlight]))
-> DocumentText
-> f DocumentText
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Highlight] [Highlight] [Highlight] [Highlight]
-> Iso
     (Maybe [Highlight])
     (Maybe [Highlight])
     (Maybe [Highlight])
     (Maybe [Highlight])
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 AnIso [Highlight] [Highlight] [Highlight] [Highlight]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON DocumentText where
  parseJSON :: Value -> Parser DocumentText
parseJSON =
    String
-> (Object -> Parser DocumentText) -> Value -> Parser DocumentText
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DocumentText"
      ( \Object
x ->
          Maybe (Sensitive Text) -> Maybe [Highlight] -> DocumentText
DocumentText'
            (Maybe (Sensitive Text) -> Maybe [Highlight] -> DocumentText)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe [Highlight] -> DocumentText)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"text")
            Parser (Maybe [Highlight] -> DocumentText)
-> Parser (Maybe [Highlight]) -> Parser DocumentText
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Highlight]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"highlights" Parser (Maybe (Maybe [Highlight]))
-> Maybe [Highlight] -> Parser (Maybe [Highlight])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Highlight]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable DocumentText

instance Prelude.NFData DocumentText