{-# 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.RDSData.Types.ArrayValue
-- 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.RDSData.Types.ArrayValue 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

-- | Contains an array.
--
-- /See:/ 'newArrayValue' smart constructor.
data ArrayValue = ArrayValue'
  { -- | An array of arrays.
    ArrayValue -> Maybe [ArrayValue]
arrayValues :: Prelude.Maybe [ArrayValue],
    -- | An array of Boolean values.
    ArrayValue -> Maybe [Bool]
booleanValues :: Prelude.Maybe [Prelude.Bool],
    -- | An array of floating-point numbers.
    ArrayValue -> Maybe [Double]
doubleValues :: Prelude.Maybe [Prelude.Double],
    -- | An array of integers.
    ArrayValue -> Maybe [Integer]
longValues :: Prelude.Maybe [Prelude.Integer],
    -- | An array of strings.
    ArrayValue -> Maybe [Text]
stringValues :: Prelude.Maybe [Prelude.Text]
  }
  deriving (ArrayValue -> ArrayValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArrayValue -> ArrayValue -> Bool
$c/= :: ArrayValue -> ArrayValue -> Bool
== :: ArrayValue -> ArrayValue -> Bool
$c== :: ArrayValue -> ArrayValue -> Bool
Prelude.Eq, ReadPrec [ArrayValue]
ReadPrec ArrayValue
Int -> ReadS ArrayValue
ReadS [ArrayValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArrayValue]
$creadListPrec :: ReadPrec [ArrayValue]
readPrec :: ReadPrec ArrayValue
$creadPrec :: ReadPrec ArrayValue
readList :: ReadS [ArrayValue]
$creadList :: ReadS [ArrayValue]
readsPrec :: Int -> ReadS ArrayValue
$creadsPrec :: Int -> ReadS ArrayValue
Prelude.Read, Int -> ArrayValue -> ShowS
[ArrayValue] -> ShowS
ArrayValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArrayValue] -> ShowS
$cshowList :: [ArrayValue] -> ShowS
show :: ArrayValue -> String
$cshow :: ArrayValue -> String
showsPrec :: Int -> ArrayValue -> ShowS
$cshowsPrec :: Int -> ArrayValue -> ShowS
Prelude.Show, forall x. Rep ArrayValue x -> ArrayValue
forall x. ArrayValue -> Rep ArrayValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArrayValue x -> ArrayValue
$cfrom :: forall x. ArrayValue -> Rep ArrayValue x
Prelude.Generic)

-- |
-- Create a value of 'ArrayValue' 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:
--
-- 'arrayValues', 'arrayValue_arrayValues' - An array of arrays.
--
-- 'booleanValues', 'arrayValue_booleanValues' - An array of Boolean values.
--
-- 'doubleValues', 'arrayValue_doubleValues' - An array of floating-point numbers.
--
-- 'longValues', 'arrayValue_longValues' - An array of integers.
--
-- 'stringValues', 'arrayValue_stringValues' - An array of strings.
newArrayValue ::
  ArrayValue
newArrayValue :: ArrayValue
newArrayValue =
  ArrayValue'
    { $sel:arrayValues:ArrayValue' :: Maybe [ArrayValue]
arrayValues = forall a. Maybe a
Prelude.Nothing,
      $sel:booleanValues:ArrayValue' :: Maybe [Bool]
booleanValues = forall a. Maybe a
Prelude.Nothing,
      $sel:doubleValues:ArrayValue' :: Maybe [Double]
doubleValues = forall a. Maybe a
Prelude.Nothing,
      $sel:longValues:ArrayValue' :: Maybe [Integer]
longValues = forall a. Maybe a
Prelude.Nothing,
      $sel:stringValues:ArrayValue' :: Maybe [Text]
stringValues = forall a. Maybe a
Prelude.Nothing
    }

-- | An array of arrays.
arrayValue_arrayValues :: Lens.Lens' ArrayValue (Prelude.Maybe [ArrayValue])
arrayValue_arrayValues :: Lens' ArrayValue (Maybe [ArrayValue])
arrayValue_arrayValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [ArrayValue]
arrayValues :: Maybe [ArrayValue]
$sel:arrayValues:ArrayValue' :: ArrayValue -> Maybe [ArrayValue]
arrayValues} -> Maybe [ArrayValue]
arrayValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [ArrayValue]
a -> ArrayValue
s {$sel:arrayValues:ArrayValue' :: Maybe [ArrayValue]
arrayValues = Maybe [ArrayValue]
a} :: ArrayValue) 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of Boolean values.
arrayValue_booleanValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Bool])
arrayValue_booleanValues :: Lens' ArrayValue (Maybe [Bool])
arrayValue_booleanValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Bool]
booleanValues :: Maybe [Bool]
$sel:booleanValues:ArrayValue' :: ArrayValue -> Maybe [Bool]
booleanValues} -> Maybe [Bool]
booleanValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Bool]
a -> ArrayValue
s {$sel:booleanValues:ArrayValue' :: Maybe [Bool]
booleanValues = Maybe [Bool]
a} :: ArrayValue) 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of floating-point numbers.
arrayValue_doubleValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Double])
arrayValue_doubleValues :: Lens' ArrayValue (Maybe [Double])
arrayValue_doubleValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Double]
doubleValues :: Maybe [Double]
$sel:doubleValues:ArrayValue' :: ArrayValue -> Maybe [Double]
doubleValues} -> Maybe [Double]
doubleValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Double]
a -> ArrayValue
s {$sel:doubleValues:ArrayValue' :: Maybe [Double]
doubleValues = Maybe [Double]
a} :: ArrayValue) 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of integers.
arrayValue_longValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Integer])
arrayValue_longValues :: Lens' ArrayValue (Maybe [Integer])
arrayValue_longValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Integer]
longValues :: Maybe [Integer]
$sel:longValues:ArrayValue' :: ArrayValue -> Maybe [Integer]
longValues} -> Maybe [Integer]
longValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Integer]
a -> ArrayValue
s {$sel:longValues:ArrayValue' :: Maybe [Integer]
longValues = Maybe [Integer]
a} :: ArrayValue) 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of strings.
arrayValue_stringValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Text])
arrayValue_stringValues :: Lens' ArrayValue (Maybe [Text])
arrayValue_stringValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Text]
stringValues :: Maybe [Text]
$sel:stringValues:ArrayValue' :: ArrayValue -> Maybe [Text]
stringValues} -> Maybe [Text]
stringValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Text]
a -> ArrayValue
s {$sel:stringValues:ArrayValue' :: Maybe [Text]
stringValues = Maybe [Text]
a} :: ArrayValue) 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ArrayValue where
  parseJSON :: Value -> Parser ArrayValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ArrayValue"
      ( \Object
x ->
          Maybe [ArrayValue]
-> Maybe [Bool]
-> Maybe [Double]
-> Maybe [Integer]
-> Maybe [Text]
-> ArrayValue
ArrayValue'
            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
"arrayValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"booleanValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"doubleValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"longValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"stringValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ArrayValue where
  hashWithSalt :: Int -> ArrayValue -> Int
hashWithSalt Int
_salt ArrayValue' {Maybe [Bool]
Maybe [Double]
Maybe [Integer]
Maybe [Text]
Maybe [ArrayValue]
stringValues :: Maybe [Text]
longValues :: Maybe [Integer]
doubleValues :: Maybe [Double]
booleanValues :: Maybe [Bool]
arrayValues :: Maybe [ArrayValue]
$sel:stringValues:ArrayValue' :: ArrayValue -> Maybe [Text]
$sel:longValues:ArrayValue' :: ArrayValue -> Maybe [Integer]
$sel:doubleValues:ArrayValue' :: ArrayValue -> Maybe [Double]
$sel:booleanValues:ArrayValue' :: ArrayValue -> Maybe [Bool]
$sel:arrayValues:ArrayValue' :: ArrayValue -> Maybe [ArrayValue]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ArrayValue]
arrayValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Bool]
booleanValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Double]
doubleValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Integer]
longValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
stringValues

instance Prelude.NFData ArrayValue where
  rnf :: ArrayValue -> ()
rnf ArrayValue' {Maybe [Bool]
Maybe [Double]
Maybe [Integer]
Maybe [Text]
Maybe [ArrayValue]
stringValues :: Maybe [Text]
longValues :: Maybe [Integer]
doubleValues :: Maybe [Double]
booleanValues :: Maybe [Bool]
arrayValues :: Maybe [ArrayValue]
$sel:stringValues:ArrayValue' :: ArrayValue -> Maybe [Text]
$sel:longValues:ArrayValue' :: ArrayValue -> Maybe [Integer]
$sel:doubleValues:ArrayValue' :: ArrayValue -> Maybe [Double]
$sel:booleanValues:ArrayValue' :: ArrayValue -> Maybe [Bool]
$sel:arrayValues:ArrayValue' :: ArrayValue -> Maybe [ArrayValue]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ArrayValue]
arrayValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Bool]
booleanValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Double]
doubleValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Integer]
longValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
stringValues

instance Data.ToJSON ArrayValue where
  toJSON :: ArrayValue -> Value
toJSON ArrayValue' {Maybe [Bool]
Maybe [Double]
Maybe [Integer]
Maybe [Text]
Maybe [ArrayValue]
stringValues :: Maybe [Text]
longValues :: Maybe [Integer]
doubleValues :: Maybe [Double]
booleanValues :: Maybe [Bool]
arrayValues :: Maybe [ArrayValue]
$sel:stringValues:ArrayValue' :: ArrayValue -> Maybe [Text]
$sel:longValues:ArrayValue' :: ArrayValue -> Maybe [Integer]
$sel:doubleValues:ArrayValue' :: ArrayValue -> Maybe [Double]
$sel:booleanValues:ArrayValue' :: ArrayValue -> Maybe [Bool]
$sel:arrayValues:ArrayValue' :: ArrayValue -> Maybe [ArrayValue]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"arrayValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ArrayValue]
arrayValues,
            (Key
"booleanValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Bool]
booleanValues,
            (Key
"doubleValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Double]
doubleValues,
            (Key
"longValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Integer]
longValues,
            (Key
"stringValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
stringValues
          ]
      )