{-# 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 #-}
module Amazonka.Glue.Types.Predicate 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.Condition
import Amazonka.Glue.Types.Logical
import qualified Amazonka.Prelude as Prelude
data Predicate = Predicate'
{
Predicate -> Maybe [Condition]
conditions :: Prelude.Maybe [Condition],
Predicate -> Maybe Logical
logical :: Prelude.Maybe Logical
}
deriving (Predicate -> Predicate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Predicate -> Predicate -> Bool
$c/= :: Predicate -> Predicate -> Bool
== :: Predicate -> Predicate -> Bool
$c== :: Predicate -> Predicate -> Bool
Prelude.Eq, ReadPrec [Predicate]
ReadPrec Predicate
Int -> ReadS Predicate
ReadS [Predicate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Predicate]
$creadListPrec :: ReadPrec [Predicate]
readPrec :: ReadPrec Predicate
$creadPrec :: ReadPrec Predicate
readList :: ReadS [Predicate]
$creadList :: ReadS [Predicate]
readsPrec :: Int -> ReadS Predicate
$creadsPrec :: Int -> ReadS Predicate
Prelude.Read, Int -> Predicate -> ShowS
[Predicate] -> ShowS
Predicate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Predicate] -> ShowS
$cshowList :: [Predicate] -> ShowS
show :: Predicate -> String
$cshow :: Predicate -> String
showsPrec :: Int -> Predicate -> ShowS
$cshowsPrec :: Int -> Predicate -> ShowS
Prelude.Show, forall x. Rep Predicate x -> Predicate
forall x. Predicate -> Rep Predicate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Predicate x -> Predicate
$cfrom :: forall x. Predicate -> Rep Predicate x
Prelude.Generic)
newPredicate ::
Predicate
newPredicate :: Predicate
newPredicate =
Predicate'
{ $sel:conditions:Predicate' :: Maybe [Condition]
conditions = forall a. Maybe a
Prelude.Nothing,
$sel:logical:Predicate' :: Maybe Logical
logical = forall a. Maybe a
Prelude.Nothing
}
predicate_conditions :: Lens.Lens' Predicate (Prelude.Maybe [Condition])
predicate_conditions :: Lens' Predicate (Maybe [Condition])
predicate_conditions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Maybe [Condition]
conditions :: Maybe [Condition]
$sel:conditions:Predicate' :: Predicate -> Maybe [Condition]
conditions} -> Maybe [Condition]
conditions) (\s :: Predicate
s@Predicate' {} Maybe [Condition]
a -> Predicate
s {$sel:conditions:Predicate' :: Maybe [Condition]
conditions = Maybe [Condition]
a} :: Predicate) 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
predicate_logical :: Lens.Lens' Predicate (Prelude.Maybe Logical)
predicate_logical :: Lens' Predicate (Maybe Logical)
predicate_logical = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Maybe Logical
logical :: Maybe Logical
$sel:logical:Predicate' :: Predicate -> Maybe Logical
logical} -> Maybe Logical
logical) (\s :: Predicate
s@Predicate' {} Maybe Logical
a -> Predicate
s {$sel:logical:Predicate' :: Maybe Logical
logical = Maybe Logical
a} :: Predicate)
instance Data.FromJSON Predicate where
parseJSON :: Value -> Parser Predicate
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Predicate"
( \Object
x ->
Maybe [Condition] -> Maybe Logical -> Predicate
Predicate'
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
"Conditions" 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
"Logical")
)
instance Prelude.Hashable Predicate where
hashWithSalt :: Int -> Predicate -> Int
hashWithSalt Int
_salt Predicate' {Maybe [Condition]
Maybe Logical
logical :: Maybe Logical
conditions :: Maybe [Condition]
$sel:logical:Predicate' :: Predicate -> Maybe Logical
$sel:conditions:Predicate' :: Predicate -> Maybe [Condition]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Condition]
conditions
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Logical
logical
instance Prelude.NFData Predicate where
rnf :: Predicate -> ()
rnf Predicate' {Maybe [Condition]
Maybe Logical
logical :: Maybe Logical
conditions :: Maybe [Condition]
$sel:logical:Predicate' :: Predicate -> Maybe Logical
$sel:conditions:Predicate' :: Predicate -> Maybe [Condition]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Condition]
conditions
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Logical
logical
instance Data.ToJSON Predicate where
toJSON :: Predicate -> Value
toJSON Predicate' {Maybe [Condition]
Maybe Logical
logical :: Maybe Logical
conditions :: Maybe [Condition]
$sel:logical:Predicate' :: Predicate -> Maybe Logical
$sel:conditions:Predicate' :: Predicate -> Maybe [Condition]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Conditions" 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 [Condition]
conditions,
(Key
"Logical" 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 Logical
logical
]
)