{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RedshiftData.Types.Field where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A data value in a column.
--
-- /See:/ 'newField' smart constructor.
data Field = Field'
  { -- | A value of the double data type.
    Field -> Maybe Double
doubleValue :: Prelude.Maybe Prelude.Double,
    -- | A value of the string data type.
    Field -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text,
    -- | A value of the long data type.
    Field -> Maybe Integer
longValue :: Prelude.Maybe Prelude.Integer,
    -- | A value of the Boolean data type.
    Field -> Maybe Bool
booleanValue :: Prelude.Maybe Prelude.Bool,
    -- | A value of the BLOB data type.
    Field -> Maybe Base64
blobValue :: Prelude.Maybe Core.Base64,
    -- | A value that indicates whether the data is NULL.
    Field -> Maybe Bool
isNull :: Prelude.Maybe Prelude.Bool
  }
  deriving (Field -> Field -> Bool
(Field -> Field -> Bool) -> (Field -> Field -> Bool) -> Eq Field
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]
(Int -> ReadS Field)
-> ReadS [Field]
-> ReadPrec Field
-> ReadPrec [Field]
-> Read 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
(Int -> Field -> ShowS)
-> (Field -> String) -> ([Field] -> ShowS) -> Show Field
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. Field -> Rep Field x)
-> (forall x. Rep Field x -> Field) -> Generic Field
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:
--
-- 'doubleValue', 'field_doubleValue' - A value of the double data type.
--
-- 'stringValue', 'field_stringValue' - A value of the string data type.
--
-- 'longValue', 'field_longValue' - A value of the long data type.
--
-- 'booleanValue', 'field_booleanValue' - A value of the Boolean data type.
--
-- '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.
--
-- 'isNull', 'field_isNull' - A value that indicates whether the data is NULL.
newField ::
  Field
newField :: Field
newField =
  Field' :: Maybe Double
-> Maybe Text
-> Maybe Integer
-> Maybe Bool
-> Maybe Base64
-> Maybe Bool
-> Field
Field'
    { $sel:doubleValue:Field' :: Maybe Double
doubleValue = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:Field' :: Maybe Text
stringValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:longValue:Field' :: Maybe Integer
longValue = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:booleanValue:Field' :: Maybe Bool
booleanValue = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:blobValue:Field' :: Maybe Base64
blobValue = Maybe Base64
forall a. Maybe a
Prelude.Nothing,
      $sel:isNull:Field' :: Maybe Bool
isNull = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | A value of the double data type.
field_doubleValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Double)
field_doubleValue :: (Maybe Double -> f (Maybe Double)) -> Field -> f Field
field_doubleValue = (Field -> Maybe Double)
-> (Field -> Maybe Double -> Field)
-> Lens Field Field (Maybe Double) (Maybe Double)
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 of the string data type.
field_stringValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Text)
field_stringValue :: (Maybe Text -> f (Maybe Text)) -> Field -> f Field
field_stringValue = (Field -> Maybe Text)
-> (Field -> Maybe Text -> Field)
-> Lens Field Field (Maybe Text) (Maybe Text)
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)

-- | A value of the long data type.
field_longValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Integer)
field_longValue :: (Maybe Integer -> f (Maybe Integer)) -> Field -> f Field
field_longValue = (Field -> Maybe Integer)
-> (Field -> Maybe Integer -> Field)
-> Lens Field Field (Maybe Integer) (Maybe Integer)
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 Boolean data type.
field_booleanValue :: Lens.Lens' Field (Prelude.Maybe Prelude.Bool)
field_booleanValue :: (Maybe Bool -> f (Maybe Bool)) -> Field -> f Field
field_booleanValue = (Field -> Maybe Bool)
-> (Field -> Maybe Bool -> Field)
-> Lens Field Field (Maybe Bool) (Maybe Bool)
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 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 :: (Maybe ByteString -> f (Maybe ByteString)) -> Field -> f Field
field_blobValue = (Field -> Maybe Base64)
-> (Field -> Maybe Base64 -> Field)
-> Lens Field Field (Maybe Base64) (Maybe Base64)
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) ((Maybe Base64 -> f (Maybe Base64)) -> Field -> f Field)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> Field
-> f Field
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
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 AnIso Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64

-- | A value that indicates whether the data is NULL.
field_isNull :: Lens.Lens' Field (Prelude.Maybe Prelude.Bool)
field_isNull :: (Maybe Bool -> f (Maybe Bool)) -> Field -> f Field
field_isNull = (Field -> Maybe Bool)
-> (Field -> Maybe Bool -> Field)
-> Lens Field Field (Maybe Bool) (Maybe Bool)
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)

instance Core.FromJSON Field where
  parseJSON :: Value -> Parser Field
parseJSON =
    String -> (Object -> Parser Field) -> Value -> Parser Field
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Field"
      ( \Object
x ->
          Maybe Double
-> Maybe Text
-> Maybe Integer
-> Maybe Bool
-> Maybe Base64
-> Maybe Bool
-> Field
Field'
            (Maybe Double
 -> Maybe Text
 -> Maybe Integer
 -> Maybe Bool
 -> Maybe Base64
 -> Maybe Bool
 -> Field)
-> Parser (Maybe Double)
-> Parser
     (Maybe Text
      -> Maybe Integer
      -> Maybe Bool
      -> Maybe Base64
      -> Maybe Bool
      -> Field)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"doubleValue")
            Parser
  (Maybe Text
   -> Maybe Integer
   -> Maybe Bool
   -> Maybe Base64
   -> Maybe Bool
   -> Field)
-> Parser (Maybe Text)
-> Parser
     (Maybe Integer
      -> Maybe Bool -> Maybe Base64 -> Maybe Bool -> Field)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stringValue")
            Parser
  (Maybe Integer
   -> Maybe Bool -> Maybe Base64 -> Maybe Bool -> Field)
-> Parser (Maybe Integer)
-> Parser (Maybe Bool -> Maybe Base64 -> Maybe Bool -> Field)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"longValue")
            Parser (Maybe Bool -> Maybe Base64 -> Maybe Bool -> Field)
-> Parser (Maybe Bool)
-> Parser (Maybe Base64 -> Maybe Bool -> Field)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"booleanValue")
            Parser (Maybe Base64 -> Maybe Bool -> Field)
-> Parser (Maybe Base64) -> Parser (Maybe Bool -> Field)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Base64)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"blobValue")
            Parser (Maybe Bool -> Field) -> Parser (Maybe Bool) -> Parser Field
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isNull")
      )

instance Prelude.Hashable Field

instance Prelude.NFData Field