{-# 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.PartitionValueList
-- 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.PartitionValueList 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 a list of values defining partitions.
--
-- /See:/ 'newPartitionValueList' smart constructor.
data PartitionValueList = PartitionValueList'
  { -- | The list of values.
    PartitionValueList -> [Text]
values :: [Prelude.Text]
  }
  deriving (PartitionValueList -> PartitionValueList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartitionValueList -> PartitionValueList -> Bool
$c/= :: PartitionValueList -> PartitionValueList -> Bool
== :: PartitionValueList -> PartitionValueList -> Bool
$c== :: PartitionValueList -> PartitionValueList -> Bool
Prelude.Eq, ReadPrec [PartitionValueList]
ReadPrec PartitionValueList
Int -> ReadS PartitionValueList
ReadS [PartitionValueList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartitionValueList]
$creadListPrec :: ReadPrec [PartitionValueList]
readPrec :: ReadPrec PartitionValueList
$creadPrec :: ReadPrec PartitionValueList
readList :: ReadS [PartitionValueList]
$creadList :: ReadS [PartitionValueList]
readsPrec :: Int -> ReadS PartitionValueList
$creadsPrec :: Int -> ReadS PartitionValueList
Prelude.Read, Int -> PartitionValueList -> ShowS
[PartitionValueList] -> ShowS
PartitionValueList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartitionValueList] -> ShowS
$cshowList :: [PartitionValueList] -> ShowS
show :: PartitionValueList -> String
$cshow :: PartitionValueList -> String
showsPrec :: Int -> PartitionValueList -> ShowS
$cshowsPrec :: Int -> PartitionValueList -> ShowS
Prelude.Show, forall x. Rep PartitionValueList x -> PartitionValueList
forall x. PartitionValueList -> Rep PartitionValueList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartitionValueList x -> PartitionValueList
$cfrom :: forall x. PartitionValueList -> Rep PartitionValueList x
Prelude.Generic)

-- |
-- Create a value of 'PartitionValueList' 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:
--
-- 'values', 'partitionValueList_values' - The list of values.
newPartitionValueList ::
  PartitionValueList
newPartitionValueList :: PartitionValueList
newPartitionValueList =
  PartitionValueList' {$sel:values:PartitionValueList' :: [Text]
values = forall a. Monoid a => a
Prelude.mempty}

-- | The list of values.
partitionValueList_values :: Lens.Lens' PartitionValueList [Prelude.Text]
partitionValueList_values :: Lens' PartitionValueList [Text]
partitionValueList_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionValueList' {[Text]
values :: [Text]
$sel:values:PartitionValueList' :: PartitionValueList -> [Text]
values} -> [Text]
values) (\s :: PartitionValueList
s@PartitionValueList' {} [Text]
a -> PartitionValueList
s {$sel:values:PartitionValueList' :: [Text]
values = [Text]
a} :: PartitionValueList) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON PartitionValueList where
  parseJSON :: Value -> Parser PartitionValueList
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PartitionValueList"
      ( \Object
x ->
          [Text] -> PartitionValueList
PartitionValueList'
            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
"Values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PartitionValueList where
  hashWithSalt :: Int -> PartitionValueList -> Int
hashWithSalt Int
_salt PartitionValueList' {[Text]
values :: [Text]
$sel:values:PartitionValueList' :: PartitionValueList -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
values

instance Prelude.NFData PartitionValueList where
  rnf :: PartitionValueList -> ()
rnf PartitionValueList' {[Text]
values :: [Text]
$sel:values:PartitionValueList' :: PartitionValueList -> [Text]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Text]
values

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