{-# 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.Kendra.Types.TableCell
-- 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.Kendra.Types.TableCell 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

-- | Provides information about a table cell in a table excerpt.
--
-- /See:/ 'newTableCell' smart constructor.
data TableCell = TableCell'
  { -- | @TRUE@ means that the table cell should be treated as a header.
    TableCell -> Maybe Bool
header :: Prelude.Maybe Prelude.Bool,
    -- | @TRUE@ means that the table cell has a high enough confidence and is
    -- relevant to the query, so the value or content should be highlighted.
    TableCell -> Maybe Bool
highlighted :: Prelude.Maybe Prelude.Bool,
    -- | @TRUE@ if the response of the table cell is the top answer. This is the
    -- cell value or content with the highest confidence score or is the most
    -- relevant to the query.
    TableCell -> Maybe Bool
topAnswer :: Prelude.Maybe Prelude.Bool,
    -- | The actual value or content within a table cell. A table cell could
    -- contain a date value of a year, or a string value of text, for example.
    TableCell -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (TableCell -> TableCell -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableCell -> TableCell -> Bool
$c/= :: TableCell -> TableCell -> Bool
== :: TableCell -> TableCell -> Bool
$c== :: TableCell -> TableCell -> Bool
Prelude.Eq, ReadPrec [TableCell]
ReadPrec TableCell
Int -> ReadS TableCell
ReadS [TableCell]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TableCell]
$creadListPrec :: ReadPrec [TableCell]
readPrec :: ReadPrec TableCell
$creadPrec :: ReadPrec TableCell
readList :: ReadS [TableCell]
$creadList :: ReadS [TableCell]
readsPrec :: Int -> ReadS TableCell
$creadsPrec :: Int -> ReadS TableCell
Prelude.Read, Int -> TableCell -> ShowS
[TableCell] -> ShowS
TableCell -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableCell] -> ShowS
$cshowList :: [TableCell] -> ShowS
show :: TableCell -> String
$cshow :: TableCell -> String
showsPrec :: Int -> TableCell -> ShowS
$cshowsPrec :: Int -> TableCell -> ShowS
Prelude.Show, forall x. Rep TableCell x -> TableCell
forall x. TableCell -> Rep TableCell x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TableCell x -> TableCell
$cfrom :: forall x. TableCell -> Rep TableCell x
Prelude.Generic)

-- |
-- Create a value of 'TableCell' 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:
--
-- 'header', 'tableCell_header' - @TRUE@ means that the table cell should be treated as a header.
--
-- 'highlighted', 'tableCell_highlighted' - @TRUE@ means that the table cell has a high enough confidence and is
-- relevant to the query, so the value or content should be highlighted.
--
-- 'topAnswer', 'tableCell_topAnswer' - @TRUE@ if the response of the table cell is the top answer. This is the
-- cell value or content with the highest confidence score or is the most
-- relevant to the query.
--
-- 'value', 'tableCell_value' - The actual value or content within a table cell. A table cell could
-- contain a date value of a year, or a string value of text, for example.
newTableCell ::
  TableCell
newTableCell :: TableCell
newTableCell =
  TableCell'
    { $sel:header:TableCell' :: Maybe Bool
header = forall a. Maybe a
Prelude.Nothing,
      $sel:highlighted:TableCell' :: Maybe Bool
highlighted = forall a. Maybe a
Prelude.Nothing,
      $sel:topAnswer:TableCell' :: Maybe Bool
topAnswer = forall a. Maybe a
Prelude.Nothing,
      $sel:value:TableCell' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | @TRUE@ means that the table cell should be treated as a header.
tableCell_header :: Lens.Lens' TableCell (Prelude.Maybe Prelude.Bool)
tableCell_header :: Lens' TableCell (Maybe Bool)
tableCell_header = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableCell' {Maybe Bool
header :: Maybe Bool
$sel:header:TableCell' :: TableCell -> Maybe Bool
header} -> Maybe Bool
header) (\s :: TableCell
s@TableCell' {} Maybe Bool
a -> TableCell
s {$sel:header:TableCell' :: Maybe Bool
header = Maybe Bool
a} :: TableCell)

-- | @TRUE@ means that the table cell has a high enough confidence and is
-- relevant to the query, so the value or content should be highlighted.
tableCell_highlighted :: Lens.Lens' TableCell (Prelude.Maybe Prelude.Bool)
tableCell_highlighted :: Lens' TableCell (Maybe Bool)
tableCell_highlighted = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableCell' {Maybe Bool
highlighted :: Maybe Bool
$sel:highlighted:TableCell' :: TableCell -> Maybe Bool
highlighted} -> Maybe Bool
highlighted) (\s :: TableCell
s@TableCell' {} Maybe Bool
a -> TableCell
s {$sel:highlighted:TableCell' :: Maybe Bool
highlighted = Maybe Bool
a} :: TableCell)

-- | @TRUE@ if the response of the table cell is the top answer. This is the
-- cell value or content with the highest confidence score or is the most
-- relevant to the query.
tableCell_topAnswer :: Lens.Lens' TableCell (Prelude.Maybe Prelude.Bool)
tableCell_topAnswer :: Lens' TableCell (Maybe Bool)
tableCell_topAnswer = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableCell' {Maybe Bool
topAnswer :: Maybe Bool
$sel:topAnswer:TableCell' :: TableCell -> Maybe Bool
topAnswer} -> Maybe Bool
topAnswer) (\s :: TableCell
s@TableCell' {} Maybe Bool
a -> TableCell
s {$sel:topAnswer:TableCell' :: Maybe Bool
topAnswer = Maybe Bool
a} :: TableCell)

-- | The actual value or content within a table cell. A table cell could
-- contain a date value of a year, or a string value of text, for example.
tableCell_value :: Lens.Lens' TableCell (Prelude.Maybe Prelude.Text)
tableCell_value :: Lens' TableCell (Maybe Text)
tableCell_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableCell' {Maybe Text
value :: Maybe Text
$sel:value:TableCell' :: TableCell -> Maybe Text
value} -> Maybe Text
value) (\s :: TableCell
s@TableCell' {} Maybe Text
a -> TableCell
s {$sel:value:TableCell' :: Maybe Text
value = Maybe Text
a} :: TableCell)

instance Data.FromJSON TableCell where
  parseJSON :: Value -> Parser TableCell
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TableCell"
      ( \Object
x ->
          Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Text -> TableCell
TableCell'
            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
"Header")
            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
"Highlighted")
            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
"TopAnswer")
            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
"Value")
      )

instance Prelude.Hashable TableCell where
  hashWithSalt :: Int -> TableCell -> Int
hashWithSalt Int
_salt TableCell' {Maybe Bool
Maybe Text
value :: Maybe Text
topAnswer :: Maybe Bool
highlighted :: Maybe Bool
header :: Maybe Bool
$sel:value:TableCell' :: TableCell -> Maybe Text
$sel:topAnswer:TableCell' :: TableCell -> Maybe Bool
$sel:highlighted:TableCell' :: TableCell -> Maybe Bool
$sel:header:TableCell' :: TableCell -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
header
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
highlighted
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
topAnswer
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData TableCell where
  rnf :: TableCell -> ()
rnf TableCell' {Maybe Bool
Maybe Text
value :: Maybe Text
topAnswer :: Maybe Bool
highlighted :: Maybe Bool
header :: Maybe Bool
$sel:value:TableCell' :: TableCell -> Maybe Text
$sel:topAnswer:TableCell' :: TableCell -> Maybe Bool
$sel:highlighted:TableCell' :: TableCell -> Maybe Bool
$sel:header:TableCell' :: TableCell -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
header
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
highlighted
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
topAnswer
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value