{-# 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-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.PropertyPredicate 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.Comparator
import qualified Amazonka.Prelude as Prelude

-- | Defines a property predicate.
--
-- /See:/ 'newPropertyPredicate' smart constructor.
data PropertyPredicate = PropertyPredicate'
  { -- | The comparator used to compare this property to others.
    PropertyPredicate -> Maybe Comparator
comparator :: Prelude.Maybe Comparator,
    -- | The key of the property.
    PropertyPredicate -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The value of the property.
    PropertyPredicate -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (PropertyPredicate -> PropertyPredicate -> Bool
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]
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
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. 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:
--
-- 'comparator', 'propertyPredicate_comparator' - The comparator used to compare this property to others.
--
-- 'key', 'propertyPredicate_key' - The key of the property.
--
-- 'value', 'propertyPredicate_value' - The value of the property.
newPropertyPredicate ::
  PropertyPredicate
newPropertyPredicate :: PropertyPredicate
newPropertyPredicate =
  PropertyPredicate'
    { $sel:comparator:PropertyPredicate' :: Maybe Comparator
comparator = forall a. Maybe a
Prelude.Nothing,
      $sel:key:PropertyPredicate' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:value:PropertyPredicate' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The comparator used to compare this property to others.
propertyPredicate_comparator :: Lens.Lens' PropertyPredicate (Prelude.Maybe Comparator)
propertyPredicate_comparator :: Lens' PropertyPredicate (Maybe Comparator)
propertyPredicate_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)

-- | The key of the property.
propertyPredicate_key :: Lens.Lens' PropertyPredicate (Prelude.Maybe Prelude.Text)
propertyPredicate_key :: Lens' PropertyPredicate (Maybe Text)
propertyPredicate_key = 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 value of the property.
propertyPredicate_value :: Lens.Lens' PropertyPredicate (Prelude.Maybe Prelude.Text)
propertyPredicate_value :: Lens' PropertyPredicate (Maybe Text)
propertyPredicate_value = 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)

instance Prelude.Hashable PropertyPredicate where
  hashWithSalt :: Int -> PropertyPredicate -> Int
hashWithSalt Int
_salt PropertyPredicate' {Maybe Text
Maybe Comparator
value :: Maybe Text
key :: Maybe Text
comparator :: Maybe Comparator
$sel:value:PropertyPredicate' :: PropertyPredicate -> Maybe Text
$sel:key:PropertyPredicate' :: PropertyPredicate -> Maybe Text
$sel:comparator:PropertyPredicate' :: PropertyPredicate -> Maybe Comparator
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Comparator
comparator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData PropertyPredicate where
  rnf :: PropertyPredicate -> ()
rnf PropertyPredicate' {Maybe Text
Maybe Comparator
value :: Maybe Text
key :: Maybe Text
comparator :: Maybe Comparator
$sel:value:PropertyPredicate' :: PropertyPredicate -> Maybe Text
$sel:key:PropertyPredicate' :: PropertyPredicate -> Maybe Text
$sel:comparator:PropertyPredicate' :: PropertyPredicate -> Maybe Comparator
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Comparator
comparator
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON PropertyPredicate where
  toJSON :: PropertyPredicate -> Value
toJSON PropertyPredicate' {Maybe Text
Maybe Comparator
value :: Maybe Text
key :: Maybe Text
comparator :: Maybe Comparator
$sel:value:PropertyPredicate' :: PropertyPredicate -> Maybe Text
$sel:key:PropertyPredicate' :: PropertyPredicate -> Maybe Text
$sel:comparator:PropertyPredicate' :: PropertyPredicate -> Maybe Comparator
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Comparator" 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 Comparator
comparator,
            (Key
"Key" 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
key,
            (Key
"Value" 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
value
          ]
      )