{-# 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.Glue.Types.NullValueField
-- 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.Glue.Types.NullValueField where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.Datatype
import qualified Amazonka.Prelude as Prelude

-- | Represents a custom null value such as a zeros or other value being used
-- as a null placeholder unique to the dataset.
--
-- /See:/ 'newNullValueField' smart constructor.
data NullValueField = NullValueField'
  { -- | The value of the null placeholder.
    NullValueField -> Text
value :: Prelude.Text,
    -- | The datatype of the value.
    NullValueField -> Datatype
datatype :: Datatype
  }
  deriving (NullValueField -> NullValueField -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NullValueField -> NullValueField -> Bool
$c/= :: NullValueField -> NullValueField -> Bool
== :: NullValueField -> NullValueField -> Bool
$c== :: NullValueField -> NullValueField -> Bool
Prelude.Eq, ReadPrec [NullValueField]
ReadPrec NullValueField
Int -> ReadS NullValueField
ReadS [NullValueField]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NullValueField]
$creadListPrec :: ReadPrec [NullValueField]
readPrec :: ReadPrec NullValueField
$creadPrec :: ReadPrec NullValueField
readList :: ReadS [NullValueField]
$creadList :: ReadS [NullValueField]
readsPrec :: Int -> ReadS NullValueField
$creadsPrec :: Int -> ReadS NullValueField
Prelude.Read, Int -> NullValueField -> ShowS
[NullValueField] -> ShowS
NullValueField -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NullValueField] -> ShowS
$cshowList :: [NullValueField] -> ShowS
show :: NullValueField -> String
$cshow :: NullValueField -> String
showsPrec :: Int -> NullValueField -> ShowS
$cshowsPrec :: Int -> NullValueField -> ShowS
Prelude.Show, forall x. Rep NullValueField x -> NullValueField
forall x. NullValueField -> Rep NullValueField x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NullValueField x -> NullValueField
$cfrom :: forall x. NullValueField -> Rep NullValueField x
Prelude.Generic)

-- |
-- Create a value of 'NullValueField' 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', 'nullValueField_value' - The value of the null placeholder.
--
-- 'datatype', 'nullValueField_datatype' - The datatype of the value.
newNullValueField ::
  -- | 'value'
  Prelude.Text ->
  -- | 'datatype'
  Datatype ->
  NullValueField
newNullValueField :: Text -> Datatype -> NullValueField
newNullValueField Text
pValue_ Datatype
pDatatype_ =
  NullValueField'
    { $sel:value:NullValueField' :: Text
value = Text
pValue_,
      $sel:datatype:NullValueField' :: Datatype
datatype = Datatype
pDatatype_
    }

-- | The value of the null placeholder.
nullValueField_value :: Lens.Lens' NullValueField Prelude.Text
nullValueField_value :: Lens' NullValueField Text
nullValueField_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NullValueField' {Text
value :: Text
$sel:value:NullValueField' :: NullValueField -> Text
value} -> Text
value) (\s :: NullValueField
s@NullValueField' {} Text
a -> NullValueField
s {$sel:value:NullValueField' :: Text
value = Text
a} :: NullValueField)

-- | The datatype of the value.
nullValueField_datatype :: Lens.Lens' NullValueField Datatype
nullValueField_datatype :: Lens' NullValueField Datatype
nullValueField_datatype = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NullValueField' {Datatype
datatype :: Datatype
$sel:datatype:NullValueField' :: NullValueField -> Datatype
datatype} -> Datatype
datatype) (\s :: NullValueField
s@NullValueField' {} Datatype
a -> NullValueField
s {$sel:datatype:NullValueField' :: Datatype
datatype = Datatype
a} :: NullValueField)

instance Data.FromJSON NullValueField where
  parseJSON :: Value -> Parser NullValueField
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NullValueField"
      ( \Object
x ->
          Text -> Datatype -> NullValueField
NullValueField'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"Datatype")
      )

instance Prelude.Hashable NullValueField where
  hashWithSalt :: Int -> NullValueField -> Int
hashWithSalt Int
_salt NullValueField' {Text
Datatype
datatype :: Datatype
value :: Text
$sel:datatype:NullValueField' :: NullValueField -> Datatype
$sel:value:NullValueField' :: NullValueField -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Datatype
datatype

instance Prelude.NFData NullValueField where
  rnf :: NullValueField -> ()
rnf NullValueField' {Text
Datatype
datatype :: Datatype
value :: Text
$sel:datatype:NullValueField' :: NullValueField -> Datatype
$sel:value:NullValueField' :: NullValueField -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Datatype
datatype

instance Data.ToJSON NullValueField where
  toJSON :: NullValueField -> Value
toJSON NullValueField' {Text
Datatype
datatype :: Datatype
value :: Text
$sel:datatype:NullValueField' :: NullValueField -> Datatype
$sel:value:NullValueField' :: NullValueField -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value),
            forall a. a -> Maybe a
Prelude.Just (Key
"Datatype" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Datatype
datatype)
          ]
      )