{-# 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.AmplifyUiBuilder.Types.Predicate 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
data Predicate = Predicate'
{
Predicate -> Maybe [Predicate]
and :: Prelude.Maybe [Predicate],
Predicate -> Maybe Text
field :: Prelude.Maybe Prelude.Text,
Predicate -> Maybe Text
operand :: Prelude.Maybe Prelude.Text,
Predicate -> Maybe Text
operator :: Prelude.Maybe Prelude.Text,
Predicate -> Maybe [Predicate]
or :: Prelude.Maybe [Predicate]
}
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:and:Predicate' :: Maybe [Predicate]
and = forall a. Maybe a
Prelude.Nothing,
$sel:field:Predicate' :: Maybe Text
field = forall a. Maybe a
Prelude.Nothing,
$sel:operand:Predicate' :: Maybe Text
operand = forall a. Maybe a
Prelude.Nothing,
$sel:operator:Predicate' :: Maybe Text
operator = forall a. Maybe a
Prelude.Nothing,
$sel:or:Predicate' :: Maybe [Predicate]
or = forall a. Maybe a
Prelude.Nothing
}
predicate_and :: Lens.Lens' Predicate (Prelude.Maybe [Predicate])
predicate_and :: Lens' Predicate (Maybe [Predicate])
predicate_and = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Maybe [Predicate]
and :: Maybe [Predicate]
$sel:and:Predicate' :: Predicate -> Maybe [Predicate]
and} -> Maybe [Predicate]
and) (\s :: Predicate
s@Predicate' {} Maybe [Predicate]
a -> Predicate
s {$sel:and:Predicate' :: Maybe [Predicate]
and = Maybe [Predicate]
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_field :: Lens.Lens' Predicate (Prelude.Maybe Prelude.Text)
predicate_field :: Lens' Predicate (Maybe Text)
predicate_field = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Maybe Text
field :: Maybe Text
$sel:field:Predicate' :: Predicate -> Maybe Text
field} -> Maybe Text
field) (\s :: Predicate
s@Predicate' {} Maybe Text
a -> Predicate
s {$sel:field:Predicate' :: Maybe Text
field = Maybe Text
a} :: Predicate)
predicate_operand :: Lens.Lens' Predicate (Prelude.Maybe Prelude.Text)
predicate_operand :: Lens' Predicate (Maybe Text)
predicate_operand = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Maybe Text
operand :: Maybe Text
$sel:operand:Predicate' :: Predicate -> Maybe Text
operand} -> Maybe Text
operand) (\s :: Predicate
s@Predicate' {} Maybe Text
a -> Predicate
s {$sel:operand:Predicate' :: Maybe Text
operand = Maybe Text
a} :: Predicate)
predicate_operator :: Lens.Lens' Predicate (Prelude.Maybe Prelude.Text)
predicate_operator :: Lens' Predicate (Maybe Text)
predicate_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Maybe Text
operator :: Maybe Text
$sel:operator:Predicate' :: Predicate -> Maybe Text
operator} -> Maybe Text
operator) (\s :: Predicate
s@Predicate' {} Maybe Text
a -> Predicate
s {$sel:operator:Predicate' :: Maybe Text
operator = Maybe Text
a} :: Predicate)
predicate_or :: Lens.Lens' Predicate (Prelude.Maybe [Predicate])
predicate_or :: Lens' Predicate (Maybe [Predicate])
predicate_or = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Predicate' {Maybe [Predicate]
or :: Maybe [Predicate]
$sel:or:Predicate' :: Predicate -> Maybe [Predicate]
or} -> Maybe [Predicate]
or) (\s :: Predicate
s@Predicate' {} Maybe [Predicate]
a -> Predicate
s {$sel:or:Predicate' :: Maybe [Predicate]
or = Maybe [Predicate]
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
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 [Predicate]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Predicate]
-> 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
"and" 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
"field")
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
"operand")
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
"operator")
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
"or" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable Predicate where
hashWithSalt :: Int -> Predicate -> Int
hashWithSalt Int
_salt Predicate' {Maybe [Predicate]
Maybe Text
or :: Maybe [Predicate]
operator :: Maybe Text
operand :: Maybe Text
field :: Maybe Text
and :: Maybe [Predicate]
$sel:or:Predicate' :: Predicate -> Maybe [Predicate]
$sel:operator:Predicate' :: Predicate -> Maybe Text
$sel:operand:Predicate' :: Predicate -> Maybe Text
$sel:field:Predicate' :: Predicate -> Maybe Text
$sel:and:Predicate' :: Predicate -> Maybe [Predicate]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Predicate]
and
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
field
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
operand
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
operator
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Predicate]
or
instance Prelude.NFData Predicate where
rnf :: Predicate -> ()
rnf Predicate' {Maybe [Predicate]
Maybe Text
or :: Maybe [Predicate]
operator :: Maybe Text
operand :: Maybe Text
field :: Maybe Text
and :: Maybe [Predicate]
$sel:or:Predicate' :: Predicate -> Maybe [Predicate]
$sel:operator:Predicate' :: Predicate -> Maybe Text
$sel:operand:Predicate' :: Predicate -> Maybe Text
$sel:field:Predicate' :: Predicate -> Maybe Text
$sel:and:Predicate' :: Predicate -> Maybe [Predicate]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Predicate]
and
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
field
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
operand
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
operator
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Predicate]
or
instance Data.ToJSON Predicate where
toJSON :: Predicate -> Value
toJSON Predicate' {Maybe [Predicate]
Maybe Text
or :: Maybe [Predicate]
operator :: Maybe Text
operand :: Maybe Text
field :: Maybe Text
and :: Maybe [Predicate]
$sel:or:Predicate' :: Predicate -> Maybe [Predicate]
$sel:operator:Predicate' :: Predicate -> Maybe Text
$sel:operand:Predicate' :: Predicate -> Maybe Text
$sel:field:Predicate' :: Predicate -> Maybe Text
$sel:and:Predicate' :: Predicate -> Maybe [Predicate]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"and" 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 [Predicate]
and,
(Key
"field" 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
field,
(Key
"operand" 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
operand,
(Key
"operator" 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
operator,
(Key
"or" 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 [Predicate]
or
]
)