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

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

-- | Offset specification to describe highlighting of document excerpts for
-- rendering search results and recommendations.
--
-- /See:/ 'newHighlight' smart constructor.
data Highlight = Highlight'
  { -- | The offset for the end of the highlight.
    Highlight -> Maybe Int
endOffsetExclusive :: Prelude.Maybe Prelude.Int,
    -- | The offset for the start of the highlight.
    Highlight -> Maybe Int
beginOffsetInclusive :: Prelude.Maybe Prelude.Int
  }
  deriving (Highlight -> Highlight -> Bool
(Highlight -> Highlight -> Bool)
-> (Highlight -> Highlight -> Bool) -> Eq Highlight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Highlight -> Highlight -> Bool
$c/= :: Highlight -> Highlight -> Bool
== :: Highlight -> Highlight -> Bool
$c== :: Highlight -> Highlight -> Bool
Prelude.Eq, ReadPrec [Highlight]
ReadPrec Highlight
Int -> ReadS Highlight
ReadS [Highlight]
(Int -> ReadS Highlight)
-> ReadS [Highlight]
-> ReadPrec Highlight
-> ReadPrec [Highlight]
-> Read Highlight
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Highlight]
$creadListPrec :: ReadPrec [Highlight]
readPrec :: ReadPrec Highlight
$creadPrec :: ReadPrec Highlight
readList :: ReadS [Highlight]
$creadList :: ReadS [Highlight]
readsPrec :: Int -> ReadS Highlight
$creadsPrec :: Int -> ReadS Highlight
Prelude.Read, Int -> Highlight -> ShowS
[Highlight] -> ShowS
Highlight -> String
(Int -> Highlight -> ShowS)
-> (Highlight -> String)
-> ([Highlight] -> ShowS)
-> Show Highlight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Highlight] -> ShowS
$cshowList :: [Highlight] -> ShowS
show :: Highlight -> String
$cshow :: Highlight -> String
showsPrec :: Int -> Highlight -> ShowS
$cshowsPrec :: Int -> Highlight -> ShowS
Prelude.Show, (forall x. Highlight -> Rep Highlight x)
-> (forall x. Rep Highlight x -> Highlight) -> Generic Highlight
forall x. Rep Highlight x -> Highlight
forall x. Highlight -> Rep Highlight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Highlight x -> Highlight
$cfrom :: forall x. Highlight -> Rep Highlight x
Prelude.Generic)

-- |
-- Create a value of 'Highlight' 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:
--
-- 'endOffsetExclusive', 'highlight_endOffsetExclusive' - The offset for the end of the highlight.
--
-- 'beginOffsetInclusive', 'highlight_beginOffsetInclusive' - The offset for the start of the highlight.
newHighlight ::
  Highlight
newHighlight :: Highlight
newHighlight =
  Highlight' :: Maybe Int -> Maybe Int -> Highlight
Highlight'
    { $sel:endOffsetExclusive:Highlight' :: Maybe Int
endOffsetExclusive = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:beginOffsetInclusive:Highlight' :: Maybe Int
beginOffsetInclusive = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The offset for the end of the highlight.
highlight_endOffsetExclusive :: Lens.Lens' Highlight (Prelude.Maybe Prelude.Int)
highlight_endOffsetExclusive :: (Maybe Int -> f (Maybe Int)) -> Highlight -> f Highlight
highlight_endOffsetExclusive = (Highlight -> Maybe Int)
-> (Highlight -> Maybe Int -> Highlight)
-> Lens Highlight Highlight (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Highlight' {Maybe Int
endOffsetExclusive :: Maybe Int
$sel:endOffsetExclusive:Highlight' :: Highlight -> Maybe Int
endOffsetExclusive} -> Maybe Int
endOffsetExclusive) (\s :: Highlight
s@Highlight' {} Maybe Int
a -> Highlight
s {$sel:endOffsetExclusive:Highlight' :: Maybe Int
endOffsetExclusive = Maybe Int
a} :: Highlight)

-- | The offset for the start of the highlight.
highlight_beginOffsetInclusive :: Lens.Lens' Highlight (Prelude.Maybe Prelude.Int)
highlight_beginOffsetInclusive :: (Maybe Int -> f (Maybe Int)) -> Highlight -> f Highlight
highlight_beginOffsetInclusive = (Highlight -> Maybe Int)
-> (Highlight -> Maybe Int -> Highlight)
-> Lens Highlight Highlight (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Highlight' {Maybe Int
beginOffsetInclusive :: Maybe Int
$sel:beginOffsetInclusive:Highlight' :: Highlight -> Maybe Int
beginOffsetInclusive} -> Maybe Int
beginOffsetInclusive) (\s :: Highlight
s@Highlight' {} Maybe Int
a -> Highlight
s {$sel:beginOffsetInclusive:Highlight' :: Maybe Int
beginOffsetInclusive = Maybe Int
a} :: Highlight)

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

instance Prelude.Hashable Highlight

instance Prelude.NFData Highlight