{-# 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.IotTwinMaker.Types.PropertyFilter
-- 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.IotTwinMaker.Types.PropertyFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types.DataValue
import qualified Amazonka.Prelude as Prelude

-- | An object that filters items returned by a property request.
--
-- /See:/ 'newPropertyFilter' smart constructor.
data PropertyFilter = PropertyFilter'
  { -- | The operator associated with this property filter.
    PropertyFilter -> Maybe Text
operator :: Prelude.Maybe Prelude.Text,
    -- | The property name associated with this property filter.
    PropertyFilter -> Maybe Text
propertyName :: Prelude.Maybe Prelude.Text,
    -- | The value associated with this property filter.
    PropertyFilter -> Maybe DataValue
value :: Prelude.Maybe DataValue
  }
  deriving (PropertyFilter -> PropertyFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyFilter -> PropertyFilter -> Bool
$c/= :: PropertyFilter -> PropertyFilter -> Bool
== :: PropertyFilter -> PropertyFilter -> Bool
$c== :: PropertyFilter -> PropertyFilter -> Bool
Prelude.Eq, ReadPrec [PropertyFilter]
ReadPrec PropertyFilter
Int -> ReadS PropertyFilter
ReadS [PropertyFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyFilter]
$creadListPrec :: ReadPrec [PropertyFilter]
readPrec :: ReadPrec PropertyFilter
$creadPrec :: ReadPrec PropertyFilter
readList :: ReadS [PropertyFilter]
$creadList :: ReadS [PropertyFilter]
readsPrec :: Int -> ReadS PropertyFilter
$creadsPrec :: Int -> ReadS PropertyFilter
Prelude.Read, Int -> PropertyFilter -> ShowS
[PropertyFilter] -> ShowS
PropertyFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyFilter] -> ShowS
$cshowList :: [PropertyFilter] -> ShowS
show :: PropertyFilter -> String
$cshow :: PropertyFilter -> String
showsPrec :: Int -> PropertyFilter -> ShowS
$cshowsPrec :: Int -> PropertyFilter -> ShowS
Prelude.Show, forall x. Rep PropertyFilter x -> PropertyFilter
forall x. PropertyFilter -> Rep PropertyFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyFilter x -> PropertyFilter
$cfrom :: forall x. PropertyFilter -> Rep PropertyFilter x
Prelude.Generic)

-- |
-- Create a value of 'PropertyFilter' 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:
--
-- 'operator', 'propertyFilter_operator' - The operator associated with this property filter.
--
-- 'propertyName', 'propertyFilter_propertyName' - The property name associated with this property filter.
--
-- 'value', 'propertyFilter_value' - The value associated with this property filter.
newPropertyFilter ::
  PropertyFilter
newPropertyFilter :: PropertyFilter
newPropertyFilter =
  PropertyFilter'
    { $sel:operator:PropertyFilter' :: Maybe Text
operator = forall a. Maybe a
Prelude.Nothing,
      $sel:propertyName:PropertyFilter' :: Maybe Text
propertyName = forall a. Maybe a
Prelude.Nothing,
      $sel:value:PropertyFilter' :: Maybe DataValue
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The operator associated with this property filter.
propertyFilter_operator :: Lens.Lens' PropertyFilter (Prelude.Maybe Prelude.Text)
propertyFilter_operator :: Lens' PropertyFilter (Maybe Text)
propertyFilter_operator = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyFilter' {Maybe Text
operator :: Maybe Text
$sel:operator:PropertyFilter' :: PropertyFilter -> Maybe Text
operator} -> Maybe Text
operator) (\s :: PropertyFilter
s@PropertyFilter' {} Maybe Text
a -> PropertyFilter
s {$sel:operator:PropertyFilter' :: Maybe Text
operator = Maybe Text
a} :: PropertyFilter)

-- | The property name associated with this property filter.
propertyFilter_propertyName :: Lens.Lens' PropertyFilter (Prelude.Maybe Prelude.Text)
propertyFilter_propertyName :: Lens' PropertyFilter (Maybe Text)
propertyFilter_propertyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyFilter' {Maybe Text
propertyName :: Maybe Text
$sel:propertyName:PropertyFilter' :: PropertyFilter -> Maybe Text
propertyName} -> Maybe Text
propertyName) (\s :: PropertyFilter
s@PropertyFilter' {} Maybe Text
a -> PropertyFilter
s {$sel:propertyName:PropertyFilter' :: Maybe Text
propertyName = Maybe Text
a} :: PropertyFilter)

-- | The value associated with this property filter.
propertyFilter_value :: Lens.Lens' PropertyFilter (Prelude.Maybe DataValue)
propertyFilter_value :: Lens' PropertyFilter (Maybe DataValue)
propertyFilter_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyFilter' {Maybe DataValue
value :: Maybe DataValue
$sel:value:PropertyFilter' :: PropertyFilter -> Maybe DataValue
value} -> Maybe DataValue
value) (\s :: PropertyFilter
s@PropertyFilter' {} Maybe DataValue
a -> PropertyFilter
s {$sel:value:PropertyFilter' :: Maybe DataValue
value = Maybe DataValue
a} :: PropertyFilter)

instance Prelude.Hashable PropertyFilter where
  hashWithSalt :: Int -> PropertyFilter -> Int
hashWithSalt Int
_salt PropertyFilter' {Maybe Text
Maybe DataValue
value :: Maybe DataValue
propertyName :: Maybe Text
operator :: Maybe Text
$sel:value:PropertyFilter' :: PropertyFilter -> Maybe DataValue
$sel:propertyName:PropertyFilter' :: PropertyFilter -> Maybe Text
$sel:operator:PropertyFilter' :: PropertyFilter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
operator
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
propertyName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DataValue
value

instance Prelude.NFData PropertyFilter where
  rnf :: PropertyFilter -> ()
rnf PropertyFilter' {Maybe Text
Maybe DataValue
value :: Maybe DataValue
propertyName :: Maybe Text
operator :: Maybe Text
$sel:value:PropertyFilter' :: PropertyFilter -> Maybe DataValue
$sel:propertyName:PropertyFilter' :: PropertyFilter -> Maybe Text
$sel:operator:PropertyFilter' :: PropertyFilter -> Maybe Text
..} =
    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 Text
propertyName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DataValue
value

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