{-# 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.Textract.Types.NormalizedValue
-- 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.Textract.Types.NormalizedValue 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
import Amazonka.Textract.Types.ValueType

-- | Contains information relating to dates in a document, including the type
-- of value, and the value.
--
-- /See:/ 'newNormalizedValue' smart constructor.
data NormalizedValue = NormalizedValue'
  { -- | The value of the date, written as Year-Month-DayTHour:Minute:Second.
    NormalizedValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The normalized type of the value detected. In this case, DATE.
    NormalizedValue -> Maybe ValueType
valueType :: Prelude.Maybe ValueType
  }
  deriving (NormalizedValue -> NormalizedValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NormalizedValue -> NormalizedValue -> Bool
$c/= :: NormalizedValue -> NormalizedValue -> Bool
== :: NormalizedValue -> NormalizedValue -> Bool
$c== :: NormalizedValue -> NormalizedValue -> Bool
Prelude.Eq, ReadPrec [NormalizedValue]
ReadPrec NormalizedValue
Int -> ReadS NormalizedValue
ReadS [NormalizedValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NormalizedValue]
$creadListPrec :: ReadPrec [NormalizedValue]
readPrec :: ReadPrec NormalizedValue
$creadPrec :: ReadPrec NormalizedValue
readList :: ReadS [NormalizedValue]
$creadList :: ReadS [NormalizedValue]
readsPrec :: Int -> ReadS NormalizedValue
$creadsPrec :: Int -> ReadS NormalizedValue
Prelude.Read, Int -> NormalizedValue -> ShowS
[NormalizedValue] -> ShowS
NormalizedValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NormalizedValue] -> ShowS
$cshowList :: [NormalizedValue] -> ShowS
show :: NormalizedValue -> String
$cshow :: NormalizedValue -> String
showsPrec :: Int -> NormalizedValue -> ShowS
$cshowsPrec :: Int -> NormalizedValue -> ShowS
Prelude.Show, forall x. Rep NormalizedValue x -> NormalizedValue
forall x. NormalizedValue -> Rep NormalizedValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NormalizedValue x -> NormalizedValue
$cfrom :: forall x. NormalizedValue -> Rep NormalizedValue x
Prelude.Generic)

-- |
-- Create a value of 'NormalizedValue' 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:
--
-- 'value', 'normalizedValue_value' - The value of the date, written as Year-Month-DayTHour:Minute:Second.
--
-- 'valueType', 'normalizedValue_valueType' - The normalized type of the value detected. In this case, DATE.
newNormalizedValue ::
  NormalizedValue
newNormalizedValue :: NormalizedValue
newNormalizedValue =
  NormalizedValue'
    { $sel:value:NormalizedValue' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing,
      $sel:valueType:NormalizedValue' :: Maybe ValueType
valueType = forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the date, written as Year-Month-DayTHour:Minute:Second.
normalizedValue_value :: Lens.Lens' NormalizedValue (Prelude.Maybe Prelude.Text)
normalizedValue_value :: Lens' NormalizedValue (Maybe Text)
normalizedValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NormalizedValue' {Maybe Text
value :: Maybe Text
$sel:value:NormalizedValue' :: NormalizedValue -> Maybe Text
value} -> Maybe Text
value) (\s :: NormalizedValue
s@NormalizedValue' {} Maybe Text
a -> NormalizedValue
s {$sel:value:NormalizedValue' :: Maybe Text
value = Maybe Text
a} :: NormalizedValue)

-- | The normalized type of the value detected. In this case, DATE.
normalizedValue_valueType :: Lens.Lens' NormalizedValue (Prelude.Maybe ValueType)
normalizedValue_valueType :: Lens' NormalizedValue (Maybe ValueType)
normalizedValue_valueType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NormalizedValue' {Maybe ValueType
valueType :: Maybe ValueType
$sel:valueType:NormalizedValue' :: NormalizedValue -> Maybe ValueType
valueType} -> Maybe ValueType
valueType) (\s :: NormalizedValue
s@NormalizedValue' {} Maybe ValueType
a -> NormalizedValue
s {$sel:valueType:NormalizedValue' :: Maybe ValueType
valueType = Maybe ValueType
a} :: NormalizedValue)

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

instance Prelude.Hashable NormalizedValue where
  hashWithSalt :: Int -> NormalizedValue -> Int
hashWithSalt Int
_salt NormalizedValue' {Maybe Text
Maybe ValueType
valueType :: Maybe ValueType
value :: Maybe Text
$sel:valueType:NormalizedValue' :: NormalizedValue -> Maybe ValueType
$sel:value:NormalizedValue' :: NormalizedValue -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ValueType
valueType

instance Prelude.NFData NormalizedValue where
  rnf :: NormalizedValue -> ()
rnf NormalizedValue' {Maybe Text
Maybe ValueType
valueType :: Maybe ValueType
value :: Maybe Text
$sel:valueType:NormalizedValue' :: NormalizedValue -> Maybe ValueType
$sel:value:NormalizedValue' :: NormalizedValue -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ValueType
valueType