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

import Amazonka.Comprehend.Types.RelationshipType
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

-- | List of child blocks for the current block.
--
-- /See:/ 'newRelationshipsListItem' smart constructor.
data RelationshipsListItem = RelationshipsListItem'
  { -- | Identifers of the child blocks.
    RelationshipsListItem -> Maybe [Text]
ids :: Prelude.Maybe [Prelude.Text],
    -- | Only supported relationship is a child relationship.
    RelationshipsListItem -> Maybe RelationshipType
type' :: Prelude.Maybe RelationshipType
  }
  deriving (RelationshipsListItem -> RelationshipsListItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelationshipsListItem -> RelationshipsListItem -> Bool
$c/= :: RelationshipsListItem -> RelationshipsListItem -> Bool
== :: RelationshipsListItem -> RelationshipsListItem -> Bool
$c== :: RelationshipsListItem -> RelationshipsListItem -> Bool
Prelude.Eq, ReadPrec [RelationshipsListItem]
ReadPrec RelationshipsListItem
Int -> ReadS RelationshipsListItem
ReadS [RelationshipsListItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelationshipsListItem]
$creadListPrec :: ReadPrec [RelationshipsListItem]
readPrec :: ReadPrec RelationshipsListItem
$creadPrec :: ReadPrec RelationshipsListItem
readList :: ReadS [RelationshipsListItem]
$creadList :: ReadS [RelationshipsListItem]
readsPrec :: Int -> ReadS RelationshipsListItem
$creadsPrec :: Int -> ReadS RelationshipsListItem
Prelude.Read, Int -> RelationshipsListItem -> ShowS
[RelationshipsListItem] -> ShowS
RelationshipsListItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelationshipsListItem] -> ShowS
$cshowList :: [RelationshipsListItem] -> ShowS
show :: RelationshipsListItem -> String
$cshow :: RelationshipsListItem -> String
showsPrec :: Int -> RelationshipsListItem -> ShowS
$cshowsPrec :: Int -> RelationshipsListItem -> ShowS
Prelude.Show, forall x. Rep RelationshipsListItem x -> RelationshipsListItem
forall x. RelationshipsListItem -> Rep RelationshipsListItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RelationshipsListItem x -> RelationshipsListItem
$cfrom :: forall x. RelationshipsListItem -> Rep RelationshipsListItem x
Prelude.Generic)

-- |
-- Create a value of 'RelationshipsListItem' 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:
--
-- 'ids', 'relationshipsListItem_ids' - Identifers of the child blocks.
--
-- 'type'', 'relationshipsListItem_type' - Only supported relationship is a child relationship.
newRelationshipsListItem ::
  RelationshipsListItem
newRelationshipsListItem :: RelationshipsListItem
newRelationshipsListItem =
  RelationshipsListItem'
    { $sel:ids:RelationshipsListItem' :: Maybe [Text]
ids = forall a. Maybe a
Prelude.Nothing,
      $sel:type':RelationshipsListItem' :: Maybe RelationshipType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | Identifers of the child blocks.
relationshipsListItem_ids :: Lens.Lens' RelationshipsListItem (Prelude.Maybe [Prelude.Text])
relationshipsListItem_ids :: Lens' RelationshipsListItem (Maybe [Text])
relationshipsListItem_ids = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationshipsListItem' {Maybe [Text]
ids :: Maybe [Text]
$sel:ids:RelationshipsListItem' :: RelationshipsListItem -> Maybe [Text]
ids} -> Maybe [Text]
ids) (\s :: RelationshipsListItem
s@RelationshipsListItem' {} Maybe [Text]
a -> RelationshipsListItem
s {$sel:ids:RelationshipsListItem' :: Maybe [Text]
ids = Maybe [Text]
a} :: RelationshipsListItem) 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

-- | Only supported relationship is a child relationship.
relationshipsListItem_type :: Lens.Lens' RelationshipsListItem (Prelude.Maybe RelationshipType)
relationshipsListItem_type :: Lens' RelationshipsListItem (Maybe RelationshipType)
relationshipsListItem_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationshipsListItem' {Maybe RelationshipType
type' :: Maybe RelationshipType
$sel:type':RelationshipsListItem' :: RelationshipsListItem -> Maybe RelationshipType
type'} -> Maybe RelationshipType
type') (\s :: RelationshipsListItem
s@RelationshipsListItem' {} Maybe RelationshipType
a -> RelationshipsListItem
s {$sel:type':RelationshipsListItem' :: Maybe RelationshipType
type' = Maybe RelationshipType
a} :: RelationshipsListItem)

instance Data.FromJSON RelationshipsListItem where
  parseJSON :: Value -> Parser RelationshipsListItem
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RelationshipsListItem"
      ( \Object
x ->
          Maybe [Text] -> Maybe RelationshipType -> RelationshipsListItem
RelationshipsListItem'
            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
"Ids" 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
"Type")
      )

instance Prelude.Hashable RelationshipsListItem where
  hashWithSalt :: Int -> RelationshipsListItem -> Int
hashWithSalt Int
_salt RelationshipsListItem' {Maybe [Text]
Maybe RelationshipType
type' :: Maybe RelationshipType
ids :: Maybe [Text]
$sel:type':RelationshipsListItem' :: RelationshipsListItem -> Maybe RelationshipType
$sel:ids:RelationshipsListItem' :: RelationshipsListItem -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ids
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RelationshipType
type'

instance Prelude.NFData RelationshipsListItem where
  rnf :: RelationshipsListItem -> ()
rnf RelationshipsListItem' {Maybe [Text]
Maybe RelationshipType
type' :: Maybe RelationshipType
ids :: Maybe [Text]
$sel:type':RelationshipsListItem' :: RelationshipsListItem -> Maybe RelationshipType
$sel:ids:RelationshipsListItem' :: RelationshipsListItem -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
ids seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RelationshipType
type'