{-# 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.Comprehend.Types.ChildBlock
-- 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.Comprehend.Types.ChildBlock 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

-- | Nested block contained within a block.
--
-- /See:/ 'newChildBlock' smart constructor.
data ChildBlock = ChildBlock'
  { -- | Offset of the start of the child block within its parent block.
    ChildBlock -> Maybe Int
beginOffset :: Prelude.Maybe Prelude.Int,
    -- | Unique identifier for the child block.
    ChildBlock -> Maybe Text
childBlockId :: Prelude.Maybe Prelude.Text,
    -- | Offset of the end of the child block within its parent block.
    ChildBlock -> Maybe Int
endOffset :: Prelude.Maybe Prelude.Int
  }
  deriving (ChildBlock -> ChildBlock -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChildBlock -> ChildBlock -> Bool
$c/= :: ChildBlock -> ChildBlock -> Bool
== :: ChildBlock -> ChildBlock -> Bool
$c== :: ChildBlock -> ChildBlock -> Bool
Prelude.Eq, ReadPrec [ChildBlock]
ReadPrec ChildBlock
Int -> ReadS ChildBlock
ReadS [ChildBlock]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChildBlock]
$creadListPrec :: ReadPrec [ChildBlock]
readPrec :: ReadPrec ChildBlock
$creadPrec :: ReadPrec ChildBlock
readList :: ReadS [ChildBlock]
$creadList :: ReadS [ChildBlock]
readsPrec :: Int -> ReadS ChildBlock
$creadsPrec :: Int -> ReadS ChildBlock
Prelude.Read, Int -> ChildBlock -> ShowS
[ChildBlock] -> ShowS
ChildBlock -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChildBlock] -> ShowS
$cshowList :: [ChildBlock] -> ShowS
show :: ChildBlock -> String
$cshow :: ChildBlock -> String
showsPrec :: Int -> ChildBlock -> ShowS
$cshowsPrec :: Int -> ChildBlock -> ShowS
Prelude.Show, forall x. Rep ChildBlock x -> ChildBlock
forall x. ChildBlock -> Rep ChildBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChildBlock x -> ChildBlock
$cfrom :: forall x. ChildBlock -> Rep ChildBlock x
Prelude.Generic)

-- |
-- Create a value of 'ChildBlock' 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:
--
-- 'beginOffset', 'childBlock_beginOffset' - Offset of the start of the child block within its parent block.
--
-- 'childBlockId', 'childBlock_childBlockId' - Unique identifier for the child block.
--
-- 'endOffset', 'childBlock_endOffset' - Offset of the end of the child block within its parent block.
newChildBlock ::
  ChildBlock
newChildBlock :: ChildBlock
newChildBlock =
  ChildBlock'
    { $sel:beginOffset:ChildBlock' :: Maybe Int
beginOffset = forall a. Maybe a
Prelude.Nothing,
      $sel:childBlockId:ChildBlock' :: Maybe Text
childBlockId = forall a. Maybe a
Prelude.Nothing,
      $sel:endOffset:ChildBlock' :: Maybe Int
endOffset = forall a. Maybe a
Prelude.Nothing
    }

-- | Offset of the start of the child block within its parent block.
childBlock_beginOffset :: Lens.Lens' ChildBlock (Prelude.Maybe Prelude.Int)
childBlock_beginOffset :: Lens' ChildBlock (Maybe Int)
childBlock_beginOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChildBlock' {Maybe Int
beginOffset :: Maybe Int
$sel:beginOffset:ChildBlock' :: ChildBlock -> Maybe Int
beginOffset} -> Maybe Int
beginOffset) (\s :: ChildBlock
s@ChildBlock' {} Maybe Int
a -> ChildBlock
s {$sel:beginOffset:ChildBlock' :: Maybe Int
beginOffset = Maybe Int
a} :: ChildBlock)

-- | Unique identifier for the child block.
childBlock_childBlockId :: Lens.Lens' ChildBlock (Prelude.Maybe Prelude.Text)
childBlock_childBlockId :: Lens' ChildBlock (Maybe Text)
childBlock_childBlockId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChildBlock' {Maybe Text
childBlockId :: Maybe Text
$sel:childBlockId:ChildBlock' :: ChildBlock -> Maybe Text
childBlockId} -> Maybe Text
childBlockId) (\s :: ChildBlock
s@ChildBlock' {} Maybe Text
a -> ChildBlock
s {$sel:childBlockId:ChildBlock' :: Maybe Text
childBlockId = Maybe Text
a} :: ChildBlock)

-- | Offset of the end of the child block within its parent block.
childBlock_endOffset :: Lens.Lens' ChildBlock (Prelude.Maybe Prelude.Int)
childBlock_endOffset :: Lens' ChildBlock (Maybe Int)
childBlock_endOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChildBlock' {Maybe Int
endOffset :: Maybe Int
$sel:endOffset:ChildBlock' :: ChildBlock -> Maybe Int
endOffset} -> Maybe Int
endOffset) (\s :: ChildBlock
s@ChildBlock' {} Maybe Int
a -> ChildBlock
s {$sel:endOffset:ChildBlock' :: Maybe Int
endOffset = Maybe Int
a} :: ChildBlock)

instance Data.FromJSON ChildBlock where
  parseJSON :: Value -> Parser ChildBlock
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChildBlock"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> Maybe Int -> ChildBlock
ChildBlock'
            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
"BeginOffset")
            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
"ChildBlockId")
            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
"EndOffset")
      )

instance Prelude.Hashable ChildBlock where
  hashWithSalt :: Int -> ChildBlock -> Int
hashWithSalt Int
_salt ChildBlock' {Maybe Int
Maybe Text
endOffset :: Maybe Int
childBlockId :: Maybe Text
beginOffset :: Maybe Int
$sel:endOffset:ChildBlock' :: ChildBlock -> Maybe Int
$sel:childBlockId:ChildBlock' :: ChildBlock -> Maybe Text
$sel:beginOffset:ChildBlock' :: ChildBlock -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
beginOffset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
childBlockId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
endOffset

instance Prelude.NFData ChildBlock where
  rnf :: ChildBlock -> ()
rnf ChildBlock' {Maybe Int
Maybe Text
endOffset :: Maybe Int
childBlockId :: Maybe Text
beginOffset :: Maybe Int
$sel:endOffset:ChildBlock' :: ChildBlock -> Maybe Int
$sel:childBlockId:ChildBlock' :: ChildBlock -> Maybe Text
$sel:beginOffset:ChildBlock' :: ChildBlock -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
beginOffset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
childBlockId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
endOffset