{-# 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.PropertyPredicate
-- 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.Glue.Types.PropertyPredicate where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.Comparator
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Defines a property predicate.
--
-- /See:/ 'newPropertyPredicate' smart constructor.
data PropertyPredicate = PropertyPredicate'
  { -- | The value of the property.
    PropertyPredicate -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The key of the property.
    PropertyPredicate -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The comparator used to compare this property to others.
    PropertyPredicate -> Maybe Comparator
comparator :: Prelude.Maybe Comparator
  }
  deriving (PropertyPredicate -> PropertyPredicate -> Bool
(PropertyPredicate -> PropertyPredicate -> Bool)
-> (PropertyPredicate -> PropertyPredicate -> Bool)
-> Eq PropertyPredicate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyPredicate -> PropertyPredicate -> Bool
$c/= :: PropertyPredicate -> PropertyPredicate -> Bool
== :: PropertyPredicate -> PropertyPredicate -> Bool
$c== :: PropertyPredicate -> PropertyPredicate -> Bool
Prelude.Eq, ReadPrec [PropertyPredicate]
ReadPrec PropertyPredicate
Int -> ReadS PropertyPredicate
ReadS [PropertyPredicate]
(Int -> ReadS PropertyPredicate)
-> ReadS [PropertyPredicate]
-> ReadPrec PropertyPredicate
-> ReadPrec [PropertyPredicate]
-> Read PropertyPredicate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyPredicate]
$creadListPrec :: ReadPrec [PropertyPredicate]
readPrec :: ReadPrec PropertyPredicate
$creadPrec :: ReadPrec PropertyPredicate
readList :: ReadS [PropertyPredicate]
$creadList :: ReadS [PropertyPredicate]
readsPrec :: Int -> ReadS PropertyPredicate
$creadsPrec :: Int -> ReadS PropertyPredicate
Prelude.Read, Int -> PropertyPredicate -> ShowS
[PropertyPredicate] -> ShowS
PropertyPredicate -> String
(Int -> PropertyPredicate -> ShowS)
-> (PropertyPredicate -> String)
-> ([PropertyPredicate] -> ShowS)
-> Show PropertyPredicate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyPredicate] -> ShowS
$cshowList :: [PropertyPredicate] -> ShowS
show :: PropertyPredicate -> String
$cshow :: PropertyPredicate -> String
showsPrec :: Int -> PropertyPredicate -> ShowS
$cshowsPrec :: Int -> PropertyPredicate -> ShowS
Prelude.Show, (forall x. PropertyPredicate -> Rep PropertyPredicate x)
-> (forall x. Rep PropertyPredicate x -> PropertyPredicate)
-> Generic PropertyPredicate
forall x. Rep PropertyPredicate x -> PropertyPredicate
forall x. PropertyPredicate -> Rep PropertyPredicate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyPredicate x -> PropertyPredicate
$cfrom :: forall x. PropertyPredicate -> Rep PropertyPredicate x
Prelude.Generic)

-- |
-- Create a value of 'PropertyPredicate' 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:
--
-- 'value', 'propertyPredicate_value' - The value of the property.
--
-- 'key', 'propertyPredicate_key' - The key of the property.
--
-- 'comparator', 'propertyPredicate_comparator' - The comparator used to compare this property to others.
newPropertyPredicate ::
  PropertyPredicate
newPropertyPredicate :: PropertyPredicate
newPropertyPredicate =
  PropertyPredicate' :: Maybe Text -> Maybe Text -> Maybe Comparator -> PropertyPredicate
PropertyPredicate'
    { $sel:value:PropertyPredicate' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:PropertyPredicate' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:comparator:PropertyPredicate' :: Maybe Comparator
comparator = Maybe Comparator
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the property.
propertyPredicate_value :: Lens.Lens' PropertyPredicate (Prelude.Maybe Prelude.Text)
propertyPredicate_value :: (Maybe Text -> f (Maybe Text))
-> PropertyPredicate -> f PropertyPredicate
propertyPredicate_value = (PropertyPredicate -> Maybe Text)
-> (PropertyPredicate -> Maybe Text -> PropertyPredicate)
-> Lens
     PropertyPredicate PropertyPredicate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyPredicate' {Maybe Text
value :: Maybe Text
$sel:value:PropertyPredicate' :: PropertyPredicate -> Maybe Text
value} -> Maybe Text
value) (\s :: PropertyPredicate
s@PropertyPredicate' {} Maybe Text
a -> PropertyPredicate
s {$sel:value:PropertyPredicate' :: Maybe Text
value = Maybe Text
a} :: PropertyPredicate)

-- | The key of the property.
propertyPredicate_key :: Lens.Lens' PropertyPredicate (Prelude.Maybe Prelude.Text)
propertyPredicate_key :: (Maybe Text -> f (Maybe Text))
-> PropertyPredicate -> f PropertyPredicate
propertyPredicate_key = (PropertyPredicate -> Maybe Text)
-> (PropertyPredicate -> Maybe Text -> PropertyPredicate)
-> Lens
     PropertyPredicate PropertyPredicate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyPredicate' {Maybe Text
key :: Maybe Text
$sel:key:PropertyPredicate' :: PropertyPredicate -> Maybe Text
key} -> Maybe Text
key) (\s :: PropertyPredicate
s@PropertyPredicate' {} Maybe Text
a -> PropertyPredicate
s {$sel:key:PropertyPredicate' :: Maybe Text
key = Maybe Text
a} :: PropertyPredicate)

-- | The comparator used to compare this property to others.
propertyPredicate_comparator :: Lens.Lens' PropertyPredicate (Prelude.Maybe Comparator)
propertyPredicate_comparator :: (Maybe Comparator -> f (Maybe Comparator))
-> PropertyPredicate -> f PropertyPredicate
propertyPredicate_comparator = (PropertyPredicate -> Maybe Comparator)
-> (PropertyPredicate -> Maybe Comparator -> PropertyPredicate)
-> Lens
     PropertyPredicate
     PropertyPredicate
     (Maybe Comparator)
     (Maybe Comparator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyPredicate' {Maybe Comparator
comparator :: Maybe Comparator
$sel:comparator:PropertyPredicate' :: PropertyPredicate -> Maybe Comparator
comparator} -> Maybe Comparator
comparator) (\s :: PropertyPredicate
s@PropertyPredicate' {} Maybe Comparator
a -> PropertyPredicate
s {$sel:comparator:PropertyPredicate' :: Maybe Comparator
comparator = Maybe Comparator
a} :: PropertyPredicate)

instance Prelude.Hashable PropertyPredicate

instance Prelude.NFData PropertyPredicate

instance Core.ToJSON PropertyPredicate where
  toJSON :: PropertyPredicate -> Value
toJSON PropertyPredicate' {Maybe Text
Maybe Comparator
comparator :: Maybe Comparator
key :: Maybe Text
value :: Maybe Text
$sel:comparator:PropertyPredicate' :: PropertyPredicate -> Maybe Comparator
$sel:key:PropertyPredicate' :: PropertyPredicate -> Maybe Text
$sel:value:PropertyPredicate' :: PropertyPredicate -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value,
            (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key,
            (Text
"Comparator" Text -> Comparator -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Comparator -> Pair) -> Maybe Comparator -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Comparator
comparator
          ]
      )