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

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

-- | The offset for the start of the highlight.
highlight_beginOffsetInclusive :: Lens.Lens' Highlight (Prelude.Maybe Prelude.Int)
highlight_beginOffsetInclusive :: Lens' Highlight (Maybe Int)
highlight_beginOffsetInclusive = 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)

-- | The offset for the end of the highlight.
highlight_endOffsetExclusive :: Lens.Lens' Highlight (Prelude.Maybe Prelude.Int)
highlight_endOffsetExclusive :: Lens' Highlight (Maybe Int)
highlight_endOffsetExclusive = 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)

instance Data.FromJSON Highlight where
  parseJSON :: Value -> Parser Highlight
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Highlight"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Highlight
Highlight'
            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
"beginOffsetInclusive")
            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
"endOffsetExclusive")
      )

instance Prelude.Hashable Highlight where
  hashWithSalt :: Int -> Highlight -> Int
hashWithSalt Int
_salt Highlight' {Maybe Int
endOffsetExclusive :: Maybe Int
beginOffsetInclusive :: Maybe Int
$sel:endOffsetExclusive:Highlight' :: Highlight -> Maybe Int
$sel:beginOffsetInclusive:Highlight' :: Highlight -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
beginOffsetInclusive
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
endOffsetExclusive

instance Prelude.NFData Highlight where
  rnf :: Highlight -> ()
rnf Highlight' {Maybe Int
endOffsetExclusive :: Maybe Int
beginOffsetInclusive :: Maybe Int
$sel:endOffsetExclusive:Highlight' :: Highlight -> Maybe Int
$sel:beginOffsetInclusive:Highlight' :: Highlight -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
beginOffsetInclusive
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
endOffsetExclusive