{-# 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.CloudDirectory.Types.TypedAttributeValueRange
-- 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.CloudDirectory.Types.TypedAttributeValueRange where

import Amazonka.CloudDirectory.Types.RangeMode
import Amazonka.CloudDirectory.Types.TypedAttributeValue
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

-- | A range of attribute values. For more information, see
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/directory_objects_range_filters.html Range Filters>.
--
-- /See:/ 'newTypedAttributeValueRange' smart constructor.
data TypedAttributeValueRange = TypedAttributeValueRange'
  { -- | The attribute value to terminate the range at.
    TypedAttributeValueRange -> Maybe TypedAttributeValue
endValue :: Prelude.Maybe TypedAttributeValue,
    -- | The value to start the range at.
    TypedAttributeValueRange -> Maybe TypedAttributeValue
startValue :: Prelude.Maybe TypedAttributeValue,
    -- | The inclusive or exclusive range start.
    TypedAttributeValueRange -> RangeMode
startMode :: RangeMode,
    -- | The inclusive or exclusive range end.
    TypedAttributeValueRange -> RangeMode
endMode :: RangeMode
  }
  deriving (TypedAttributeValueRange -> TypedAttributeValueRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypedAttributeValueRange -> TypedAttributeValueRange -> Bool
$c/= :: TypedAttributeValueRange -> TypedAttributeValueRange -> Bool
== :: TypedAttributeValueRange -> TypedAttributeValueRange -> Bool
$c== :: TypedAttributeValueRange -> TypedAttributeValueRange -> Bool
Prelude.Eq, ReadPrec [TypedAttributeValueRange]
ReadPrec TypedAttributeValueRange
Int -> ReadS TypedAttributeValueRange
ReadS [TypedAttributeValueRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TypedAttributeValueRange]
$creadListPrec :: ReadPrec [TypedAttributeValueRange]
readPrec :: ReadPrec TypedAttributeValueRange
$creadPrec :: ReadPrec TypedAttributeValueRange
readList :: ReadS [TypedAttributeValueRange]
$creadList :: ReadS [TypedAttributeValueRange]
readsPrec :: Int -> ReadS TypedAttributeValueRange
$creadsPrec :: Int -> ReadS TypedAttributeValueRange
Prelude.Read, Int -> TypedAttributeValueRange -> ShowS
[TypedAttributeValueRange] -> ShowS
TypedAttributeValueRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TypedAttributeValueRange] -> ShowS
$cshowList :: [TypedAttributeValueRange] -> ShowS
show :: TypedAttributeValueRange -> String
$cshow :: TypedAttributeValueRange -> String
showsPrec :: Int -> TypedAttributeValueRange -> ShowS
$cshowsPrec :: Int -> TypedAttributeValueRange -> ShowS
Prelude.Show, forall x.
Rep TypedAttributeValueRange x -> TypedAttributeValueRange
forall x.
TypedAttributeValueRange -> Rep TypedAttributeValueRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TypedAttributeValueRange x -> TypedAttributeValueRange
$cfrom :: forall x.
TypedAttributeValueRange -> Rep TypedAttributeValueRange x
Prelude.Generic)

-- |
-- Create a value of 'TypedAttributeValueRange' 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:
--
-- 'endValue', 'typedAttributeValueRange_endValue' - The attribute value to terminate the range at.
--
-- 'startValue', 'typedAttributeValueRange_startValue' - The value to start the range at.
--
-- 'startMode', 'typedAttributeValueRange_startMode' - The inclusive or exclusive range start.
--
-- 'endMode', 'typedAttributeValueRange_endMode' - The inclusive or exclusive range end.
newTypedAttributeValueRange ::
  -- | 'startMode'
  RangeMode ->
  -- | 'endMode'
  RangeMode ->
  TypedAttributeValueRange
newTypedAttributeValueRange :: RangeMode -> RangeMode -> TypedAttributeValueRange
newTypedAttributeValueRange RangeMode
pStartMode_ RangeMode
pEndMode_ =
  TypedAttributeValueRange'
    { $sel:endValue:TypedAttributeValueRange' :: Maybe TypedAttributeValue
endValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:startValue:TypedAttributeValueRange' :: Maybe TypedAttributeValue
startValue = forall a. Maybe a
Prelude.Nothing,
      $sel:startMode:TypedAttributeValueRange' :: RangeMode
startMode = RangeMode
pStartMode_,
      $sel:endMode:TypedAttributeValueRange' :: RangeMode
endMode = RangeMode
pEndMode_
    }

-- | The attribute value to terminate the range at.
typedAttributeValueRange_endValue :: Lens.Lens' TypedAttributeValueRange (Prelude.Maybe TypedAttributeValue)
typedAttributeValueRange_endValue :: Lens' TypedAttributeValueRange (Maybe TypedAttributeValue)
typedAttributeValueRange_endValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedAttributeValueRange' {Maybe TypedAttributeValue
endValue :: Maybe TypedAttributeValue
$sel:endValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
endValue} -> Maybe TypedAttributeValue
endValue) (\s :: TypedAttributeValueRange
s@TypedAttributeValueRange' {} Maybe TypedAttributeValue
a -> TypedAttributeValueRange
s {$sel:endValue:TypedAttributeValueRange' :: Maybe TypedAttributeValue
endValue = Maybe TypedAttributeValue
a} :: TypedAttributeValueRange)

-- | The value to start the range at.
typedAttributeValueRange_startValue :: Lens.Lens' TypedAttributeValueRange (Prelude.Maybe TypedAttributeValue)
typedAttributeValueRange_startValue :: Lens' TypedAttributeValueRange (Maybe TypedAttributeValue)
typedAttributeValueRange_startValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedAttributeValueRange' {Maybe TypedAttributeValue
startValue :: Maybe TypedAttributeValue
$sel:startValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
startValue} -> Maybe TypedAttributeValue
startValue) (\s :: TypedAttributeValueRange
s@TypedAttributeValueRange' {} Maybe TypedAttributeValue
a -> TypedAttributeValueRange
s {$sel:startValue:TypedAttributeValueRange' :: Maybe TypedAttributeValue
startValue = Maybe TypedAttributeValue
a} :: TypedAttributeValueRange)

-- | The inclusive or exclusive range start.
typedAttributeValueRange_startMode :: Lens.Lens' TypedAttributeValueRange RangeMode
typedAttributeValueRange_startMode :: Lens' TypedAttributeValueRange RangeMode
typedAttributeValueRange_startMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedAttributeValueRange' {RangeMode
startMode :: RangeMode
$sel:startMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
startMode} -> RangeMode
startMode) (\s :: TypedAttributeValueRange
s@TypedAttributeValueRange' {} RangeMode
a -> TypedAttributeValueRange
s {$sel:startMode:TypedAttributeValueRange' :: RangeMode
startMode = RangeMode
a} :: TypedAttributeValueRange)

-- | The inclusive or exclusive range end.
typedAttributeValueRange_endMode :: Lens.Lens' TypedAttributeValueRange RangeMode
typedAttributeValueRange_endMode :: Lens' TypedAttributeValueRange RangeMode
typedAttributeValueRange_endMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TypedAttributeValueRange' {RangeMode
endMode :: RangeMode
$sel:endMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
endMode} -> RangeMode
endMode) (\s :: TypedAttributeValueRange
s@TypedAttributeValueRange' {} RangeMode
a -> TypedAttributeValueRange
s {$sel:endMode:TypedAttributeValueRange' :: RangeMode
endMode = RangeMode
a} :: TypedAttributeValueRange)

instance Prelude.Hashable TypedAttributeValueRange where
  hashWithSalt :: Int -> TypedAttributeValueRange -> Int
hashWithSalt Int
_salt TypedAttributeValueRange' {Maybe TypedAttributeValue
RangeMode
endMode :: RangeMode
startMode :: RangeMode
startValue :: Maybe TypedAttributeValue
endValue :: Maybe TypedAttributeValue
$sel:endMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
$sel:startMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
$sel:startValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
$sel:endValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TypedAttributeValue
endValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TypedAttributeValue
startValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RangeMode
startMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RangeMode
endMode

instance Prelude.NFData TypedAttributeValueRange where
  rnf :: TypedAttributeValueRange -> ()
rnf TypedAttributeValueRange' {Maybe TypedAttributeValue
RangeMode
endMode :: RangeMode
startMode :: RangeMode
startValue :: Maybe TypedAttributeValue
endValue :: Maybe TypedAttributeValue
$sel:endMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
$sel:startMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
$sel:startValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
$sel:endValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TypedAttributeValue
endValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TypedAttributeValue
startValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RangeMode
startMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RangeMode
endMode

instance Data.ToJSON TypedAttributeValueRange where
  toJSON :: TypedAttributeValueRange -> Value
toJSON TypedAttributeValueRange' {Maybe TypedAttributeValue
RangeMode
endMode :: RangeMode
startMode :: RangeMode
startValue :: Maybe TypedAttributeValue
endValue :: Maybe TypedAttributeValue
$sel:endMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
$sel:startMode:TypedAttributeValueRange' :: TypedAttributeValueRange -> RangeMode
$sel:startValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
$sel:endValue:TypedAttributeValueRange' :: TypedAttributeValueRange -> Maybe TypedAttributeValue
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EndValue" 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 TypedAttributeValue
endValue,
            (Key
"StartValue" 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 TypedAttributeValue
startValue,
            forall a. a -> Maybe a
Prelude.Just (Key
"StartMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RangeMode
startMode),
            forall a. a -> Maybe a
Prelude.Just (Key
"EndMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RangeMode
endMode)
          ]
      )