{-# 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.RedshiftData.Types.Field
-- 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.RedshiftData.Types.Field 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

-- | A data value in a column.
--
-- /See:/ 'newField' smart constructor.
data Field = Field'
  { -- | A value of the BLOB data type.
    Field -> Maybe Base64
blobValue :: Prelude.Maybe Data.Base64,
    -- | A value of the Boolean data type.
    Field -> Maybe Bool
booleanValue :: Prelude.Maybe Prelude.Bool,
    -- | A value of the double data type.
    Field -> Maybe Double
doubleValue :: Prelude.Maybe Prelude.Double,
    -- | A value that indicates whether the data is NULL.
    Field -> Maybe Bool
isNull :: Prelude.Maybe Prelude.Bool,
    -- | A value of the long data type.
    Field -> Maybe Integer
longValue :: Prelude.Maybe Prelude.Integer,
    -- | A value of the string data type.
    Field -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text
  }
  deriving (Field -> Field -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Field -> Field -> Bool
$c/= :: Field -> Field -> Bool
== :: Field -> Field -> Bool
$c== :: Field -> Field -> Bool
Prelude.Eq, ReadPrec [Field]
ReadPrec Field
Int -> ReadS Field
ReadS [Field]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Field]
$creadListPrec :: ReadPrec [Field]
readPrec :: ReadPrec Field
$creadPrec :: ReadPrec Field
readList :: ReadS [Field]
$creadList :: ReadS [Field]
readsPrec :: Int -> ReadS Field
$creadsPrec :: Int -> ReadS Field
Prelude.Read, Int -> Field -> ShowS
[Field] -> ShowS
Field -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Field] -> ShowS
$cshowList :: [Field] -> ShowS
show :: Field -> String
$cshow :: Field -> String
showsPrec :: Int -> Field -> ShowS
$cshowsPrec :: Int -> Field -> ShowS
Prelude.Show, forall x. Rep Field x -> Field
forall x. Field -> Rep Field x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Field x -> Field
$cfrom :: forall x. Field -> Rep Field x
Prelude.Generic)

-- |
-- Create a value of 'Field' 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:
--
-- 'blobValue', 'field_blobValue' - A value of the BLOB data type.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'booleanValue', 'field_booleanValue' - A value of the Boolean data type.
--
-- 'doubleValue', 'field_doubleValue' - A value of the double data type.
--
-- 'isNull', 'field_isNull' - A value that indicates whether the data is NULL.
--
-- 'longValue', 'field_longValue' - A value of the long data type.
--
-- 'stringValue', 'field_stringValue' - A value of the string data type.
newField ::
  Field
newField :: Field
newField =
  Field'
    { $sel:blobValue:Field' :: Maybe Base64
blobValue = forall a. Maybe a
Prelude.Nothing,
      $sel:booleanValue:Field' :: Maybe Bool
booleanValue = forall a. Maybe a
Prelude.Nothing,
      $sel:doubleValue:Field' :: Maybe Double
doubleValue = forall a. Maybe a
Prelude.Nothing,
      $sel:isNull:Field' :: Maybe Bool
isNull = forall a. Maybe a
Prelude.Nothing,
      $sel:longValue:Field' :: Maybe Integer
longValue = forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:Field' :: Maybe Text
stringValue = forall a. Maybe a
Prelude.Nothing
    }

-- | A value of the BLOB data type.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
field_blobValue :: Lens.Lens' Field (Prelude.Maybe Prelude.ByteString)
field_blobValue :: Lens' Field (Maybe ByteString)
field_blobValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Field' {Maybe Base64
blobValue :: Maybe Base64
$sel:blobValue:Field' :: Field -> Maybe Base64
blobValue} -> Maybe Base64
blobValue) (\s :: Field
s@Field' {} Maybe Base64
a -> Field
s {$sel:blobValue:Field' :: Maybe Base64
blobValue = Maybe Base64
a} :: Field) 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 Iso' Base64 ByteString
Data._Base64

-- | A value of the Boolean data type.
field_booleanValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Bool)
field_booleanValue :: Lens' Field (Maybe Bool)
field_booleanValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Field' {Maybe Bool
booleanValue :: Maybe Bool
$sel:booleanValue:Field' :: Field -> Maybe Bool
booleanValue} -> Maybe Bool
booleanValue) (\s :: Field
s@Field' {} Maybe Bool
a -> Field
s {$sel:booleanValue:Field' :: Maybe Bool
booleanValue = Maybe Bool
a} :: Field)

-- | A value of the double data type.
field_doubleValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Double)
field_doubleValue :: Lens' Field (Maybe Double)
field_doubleValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Field' {Maybe Double
doubleValue :: Maybe Double
$sel:doubleValue:Field' :: Field -> Maybe Double
doubleValue} -> Maybe Double
doubleValue) (\s :: Field
s@Field' {} Maybe Double
a -> Field
s {$sel:doubleValue:Field' :: Maybe Double
doubleValue = Maybe Double
a} :: Field)

-- | A value that indicates whether the data is NULL.
field_isNull :: Lens.Lens' Field (Prelude.Maybe Prelude.Bool)
field_isNull :: Lens' Field (Maybe Bool)
field_isNull = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Field' {Maybe Bool
isNull :: Maybe Bool
$sel:isNull:Field' :: Field -> Maybe Bool
isNull} -> Maybe Bool
isNull) (\s :: Field
s@Field' {} Maybe Bool
a -> Field
s {$sel:isNull:Field' :: Maybe Bool
isNull = Maybe Bool
a} :: Field)

-- | A value of the long data type.
field_longValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Integer)
field_longValue :: Lens' Field (Maybe Integer)
field_longValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Field' {Maybe Integer
longValue :: Maybe Integer
$sel:longValue:Field' :: Field -> Maybe Integer
longValue} -> Maybe Integer
longValue) (\s :: Field
s@Field' {} Maybe Integer
a -> Field
s {$sel:longValue:Field' :: Maybe Integer
longValue = Maybe Integer
a} :: Field)

-- | A value of the string data type.
field_stringValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Text)
field_stringValue :: Lens' Field (Maybe Text)
field_stringValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Field' {Maybe Text
stringValue :: Maybe Text
$sel:stringValue:Field' :: Field -> Maybe Text
stringValue} -> Maybe Text
stringValue) (\s :: Field
s@Field' {} Maybe Text
a -> Field
s {$sel:stringValue:Field' :: Maybe Text
stringValue = Maybe Text
a} :: Field)

instance Data.FromJSON Field where
  parseJSON :: Value -> Parser Field
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Field"
      ( \Object
x ->
          Maybe Base64
-> Maybe Bool
-> Maybe Double
-> Maybe Bool
-> Maybe Integer
-> Maybe Text
-> Field
Field'
            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
"blobValue")
            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
"booleanValue")
            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
"doubleValue")
            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
"isNull")
            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
"longValue")
            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
"stringValue")
      )

instance Prelude.Hashable Field where
  hashWithSalt :: Int -> Field -> Int
hashWithSalt Int
_salt Field' {Maybe Bool
Maybe Double
Maybe Integer
Maybe Text
Maybe Base64
stringValue :: Maybe Text
longValue :: Maybe Integer
isNull :: Maybe Bool
doubleValue :: Maybe Double
booleanValue :: Maybe Bool
blobValue :: Maybe Base64
$sel:stringValue:Field' :: Field -> Maybe Text
$sel:longValue:Field' :: Field -> Maybe Integer
$sel:isNull:Field' :: Field -> Maybe Bool
$sel:doubleValue:Field' :: Field -> Maybe Double
$sel:booleanValue:Field' :: Field -> Maybe Bool
$sel:blobValue:Field' :: Field -> Maybe Base64
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Base64
blobValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
booleanValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
doubleValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isNull
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
longValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stringValue

instance Prelude.NFData Field where
  rnf :: Field -> ()
rnf Field' {Maybe Bool
Maybe Double
Maybe Integer
Maybe Text
Maybe Base64
stringValue :: Maybe Text
longValue :: Maybe Integer
isNull :: Maybe Bool
doubleValue :: Maybe Double
booleanValue :: Maybe Bool
blobValue :: Maybe Base64
$sel:stringValue:Field' :: Field -> Maybe Text
$sel:longValue:Field' :: Field -> Maybe Integer
$sel:isNull:Field' :: Field -> Maybe Bool
$sel:doubleValue:Field' :: Field -> Maybe Double
$sel:booleanValue:Field' :: Field -> Maybe Bool
$sel:blobValue:Field' :: Field -> Maybe Base64
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
blobValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
booleanValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
doubleValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isNull
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
longValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stringValue