{-# 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.IoTEventsData.Types.SimpleRuleEvaluation
-- 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.IoTEventsData.Types.SimpleRuleEvaluation where

import qualified Amazonka.Core as Core
import Amazonka.IoTEventsData.Types.ComparisonOperator
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information needed to compare two values with a comparison operator.
--
-- /See:/ 'newSimpleRuleEvaluation' smart constructor.
data SimpleRuleEvaluation = SimpleRuleEvaluation'
  { -- | The threshold value, on the right side of the comparison operator.
    SimpleRuleEvaluation -> Maybe Text
thresholdValue :: Prelude.Maybe Prelude.Text,
    -- | The value of the input property, on the left side of the comparison
    -- operator.
    SimpleRuleEvaluation -> Maybe Text
inputPropertyValue :: Prelude.Maybe Prelude.Text,
    -- | The comparison operator.
    SimpleRuleEvaluation -> Maybe ComparisonOperator
operator :: Prelude.Maybe ComparisonOperator
  }
  deriving (SimpleRuleEvaluation -> SimpleRuleEvaluation -> Bool
(SimpleRuleEvaluation -> SimpleRuleEvaluation -> Bool)
-> (SimpleRuleEvaluation -> SimpleRuleEvaluation -> Bool)
-> Eq SimpleRuleEvaluation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimpleRuleEvaluation -> SimpleRuleEvaluation -> Bool
$c/= :: SimpleRuleEvaluation -> SimpleRuleEvaluation -> Bool
== :: SimpleRuleEvaluation -> SimpleRuleEvaluation -> Bool
$c== :: SimpleRuleEvaluation -> SimpleRuleEvaluation -> Bool
Prelude.Eq, ReadPrec [SimpleRuleEvaluation]
ReadPrec SimpleRuleEvaluation
Int -> ReadS SimpleRuleEvaluation
ReadS [SimpleRuleEvaluation]
(Int -> ReadS SimpleRuleEvaluation)
-> ReadS [SimpleRuleEvaluation]
-> ReadPrec SimpleRuleEvaluation
-> ReadPrec [SimpleRuleEvaluation]
-> Read SimpleRuleEvaluation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimpleRuleEvaluation]
$creadListPrec :: ReadPrec [SimpleRuleEvaluation]
readPrec :: ReadPrec SimpleRuleEvaluation
$creadPrec :: ReadPrec SimpleRuleEvaluation
readList :: ReadS [SimpleRuleEvaluation]
$creadList :: ReadS [SimpleRuleEvaluation]
readsPrec :: Int -> ReadS SimpleRuleEvaluation
$creadsPrec :: Int -> ReadS SimpleRuleEvaluation
Prelude.Read, Int -> SimpleRuleEvaluation -> ShowS
[SimpleRuleEvaluation] -> ShowS
SimpleRuleEvaluation -> String
(Int -> SimpleRuleEvaluation -> ShowS)
-> (SimpleRuleEvaluation -> String)
-> ([SimpleRuleEvaluation] -> ShowS)
-> Show SimpleRuleEvaluation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimpleRuleEvaluation] -> ShowS
$cshowList :: [SimpleRuleEvaluation] -> ShowS
show :: SimpleRuleEvaluation -> String
$cshow :: SimpleRuleEvaluation -> String
showsPrec :: Int -> SimpleRuleEvaluation -> ShowS
$cshowsPrec :: Int -> SimpleRuleEvaluation -> ShowS
Prelude.Show, (forall x. SimpleRuleEvaluation -> Rep SimpleRuleEvaluation x)
-> (forall x. Rep SimpleRuleEvaluation x -> SimpleRuleEvaluation)
-> Generic SimpleRuleEvaluation
forall x. Rep SimpleRuleEvaluation x -> SimpleRuleEvaluation
forall x. SimpleRuleEvaluation -> Rep SimpleRuleEvaluation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SimpleRuleEvaluation x -> SimpleRuleEvaluation
$cfrom :: forall x. SimpleRuleEvaluation -> Rep SimpleRuleEvaluation x
Prelude.Generic)

-- |
-- Create a value of 'SimpleRuleEvaluation' 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:
--
-- 'thresholdValue', 'simpleRuleEvaluation_thresholdValue' - The threshold value, on the right side of the comparison operator.
--
-- 'inputPropertyValue', 'simpleRuleEvaluation_inputPropertyValue' - The value of the input property, on the left side of the comparison
-- operator.
--
-- 'operator', 'simpleRuleEvaluation_operator' - The comparison operator.
newSimpleRuleEvaluation ::
  SimpleRuleEvaluation
newSimpleRuleEvaluation :: SimpleRuleEvaluation
newSimpleRuleEvaluation =
  SimpleRuleEvaluation' :: Maybe Text
-> Maybe Text -> Maybe ComparisonOperator -> SimpleRuleEvaluation
SimpleRuleEvaluation'
    { $sel:thresholdValue:SimpleRuleEvaluation' :: Maybe Text
thresholdValue =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:inputPropertyValue:SimpleRuleEvaluation' :: Maybe Text
inputPropertyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:operator:SimpleRuleEvaluation' :: Maybe ComparisonOperator
operator = Maybe ComparisonOperator
forall a. Maybe a
Prelude.Nothing
    }

-- | The threshold value, on the right side of the comparison operator.
simpleRuleEvaluation_thresholdValue :: Lens.Lens' SimpleRuleEvaluation (Prelude.Maybe Prelude.Text)
simpleRuleEvaluation_thresholdValue :: (Maybe Text -> f (Maybe Text))
-> SimpleRuleEvaluation -> f SimpleRuleEvaluation
simpleRuleEvaluation_thresholdValue = (SimpleRuleEvaluation -> Maybe Text)
-> (SimpleRuleEvaluation -> Maybe Text -> SimpleRuleEvaluation)
-> Lens
     SimpleRuleEvaluation SimpleRuleEvaluation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleRuleEvaluation' {Maybe Text
thresholdValue :: Maybe Text
$sel:thresholdValue:SimpleRuleEvaluation' :: SimpleRuleEvaluation -> Maybe Text
thresholdValue} -> Maybe Text
thresholdValue) (\s :: SimpleRuleEvaluation
s@SimpleRuleEvaluation' {} Maybe Text
a -> SimpleRuleEvaluation
s {$sel:thresholdValue:SimpleRuleEvaluation' :: Maybe Text
thresholdValue = Maybe Text
a} :: SimpleRuleEvaluation)

-- | The value of the input property, on the left side of the comparison
-- operator.
simpleRuleEvaluation_inputPropertyValue :: Lens.Lens' SimpleRuleEvaluation (Prelude.Maybe Prelude.Text)
simpleRuleEvaluation_inputPropertyValue :: (Maybe Text -> f (Maybe Text))
-> SimpleRuleEvaluation -> f SimpleRuleEvaluation
simpleRuleEvaluation_inputPropertyValue = (SimpleRuleEvaluation -> Maybe Text)
-> (SimpleRuleEvaluation -> Maybe Text -> SimpleRuleEvaluation)
-> Lens
     SimpleRuleEvaluation SimpleRuleEvaluation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleRuleEvaluation' {Maybe Text
inputPropertyValue :: Maybe Text
$sel:inputPropertyValue:SimpleRuleEvaluation' :: SimpleRuleEvaluation -> Maybe Text
inputPropertyValue} -> Maybe Text
inputPropertyValue) (\s :: SimpleRuleEvaluation
s@SimpleRuleEvaluation' {} Maybe Text
a -> SimpleRuleEvaluation
s {$sel:inputPropertyValue:SimpleRuleEvaluation' :: Maybe Text
inputPropertyValue = Maybe Text
a} :: SimpleRuleEvaluation)

-- | The comparison operator.
simpleRuleEvaluation_operator :: Lens.Lens' SimpleRuleEvaluation (Prelude.Maybe ComparisonOperator)
simpleRuleEvaluation_operator :: (Maybe ComparisonOperator -> f (Maybe ComparisonOperator))
-> SimpleRuleEvaluation -> f SimpleRuleEvaluation
simpleRuleEvaluation_operator = (SimpleRuleEvaluation -> Maybe ComparisonOperator)
-> (SimpleRuleEvaluation
    -> Maybe ComparisonOperator -> SimpleRuleEvaluation)
-> Lens
     SimpleRuleEvaluation
     SimpleRuleEvaluation
     (Maybe ComparisonOperator)
     (Maybe ComparisonOperator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleRuleEvaluation' {Maybe ComparisonOperator
operator :: Maybe ComparisonOperator
$sel:operator:SimpleRuleEvaluation' :: SimpleRuleEvaluation -> Maybe ComparisonOperator
operator} -> Maybe ComparisonOperator
operator) (\s :: SimpleRuleEvaluation
s@SimpleRuleEvaluation' {} Maybe ComparisonOperator
a -> SimpleRuleEvaluation
s {$sel:operator:SimpleRuleEvaluation' :: Maybe ComparisonOperator
operator = Maybe ComparisonOperator
a} :: SimpleRuleEvaluation)

instance Core.FromJSON SimpleRuleEvaluation where
  parseJSON :: Value -> Parser SimpleRuleEvaluation
parseJSON =
    String
-> (Object -> Parser SimpleRuleEvaluation)
-> Value
-> Parser SimpleRuleEvaluation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SimpleRuleEvaluation"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe ComparisonOperator -> SimpleRuleEvaluation
SimpleRuleEvaluation'
            (Maybe Text
 -> Maybe Text -> Maybe ComparisonOperator -> SimpleRuleEvaluation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe ComparisonOperator -> SimpleRuleEvaluation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"thresholdValue")
            Parser
  (Maybe Text -> Maybe ComparisonOperator -> SimpleRuleEvaluation)
-> Parser (Maybe Text)
-> Parser (Maybe ComparisonOperator -> SimpleRuleEvaluation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inputPropertyValue")
            Parser (Maybe ComparisonOperator -> SimpleRuleEvaluation)
-> Parser (Maybe ComparisonOperator) -> Parser SimpleRuleEvaluation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ComparisonOperator)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"operator")
      )

instance Prelude.Hashable SimpleRuleEvaluation

instance Prelude.NFData SimpleRuleEvaluation