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

import Amazonka.CloudDirectory.Types.RangeMode
import Amazonka.CloudDirectory.Types.TypedAttributeValue
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(TypedAttributeValueRange -> TypedAttributeValueRange -> Bool)
-> (TypedAttributeValueRange -> TypedAttributeValueRange -> Bool)
-> Eq TypedAttributeValueRange
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]
(Int -> ReadS TypedAttributeValueRange)
-> ReadS [TypedAttributeValueRange]
-> ReadPrec TypedAttributeValueRange
-> ReadPrec [TypedAttributeValueRange]
-> Read 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
(Int -> TypedAttributeValueRange -> ShowS)
-> (TypedAttributeValueRange -> String)
-> ([TypedAttributeValueRange] -> ShowS)
-> Show TypedAttributeValueRange
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.
 TypedAttributeValueRange -> Rep TypedAttributeValueRange x)
-> (forall x.
    Rep TypedAttributeValueRange x -> TypedAttributeValueRange)
-> Generic TypedAttributeValueRange
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' :: Maybe TypedAttributeValue
-> Maybe TypedAttributeValue
-> RangeMode
-> RangeMode
-> TypedAttributeValueRange
TypedAttributeValueRange'
    { $sel:endValue:TypedAttributeValueRange' :: Maybe TypedAttributeValue
endValue =
        Maybe TypedAttributeValue
forall a. Maybe a
Prelude.Nothing,
      $sel:startValue:TypedAttributeValueRange' :: Maybe TypedAttributeValue
startValue = Maybe TypedAttributeValue
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 :: (Maybe TypedAttributeValue -> f (Maybe TypedAttributeValue))
-> TypedAttributeValueRange -> f TypedAttributeValueRange
typedAttributeValueRange_endValue = (TypedAttributeValueRange -> Maybe TypedAttributeValue)
-> (TypedAttributeValueRange
    -> Maybe TypedAttributeValue -> TypedAttributeValueRange)
-> Lens
     TypedAttributeValueRange
     TypedAttributeValueRange
     (Maybe TypedAttributeValue)
     (Maybe TypedAttributeValue)
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 :: (Maybe TypedAttributeValue -> f (Maybe TypedAttributeValue))
-> TypedAttributeValueRange -> f TypedAttributeValueRange
typedAttributeValueRange_startValue = (TypedAttributeValueRange -> Maybe TypedAttributeValue)
-> (TypedAttributeValueRange
    -> Maybe TypedAttributeValue -> TypedAttributeValueRange)
-> Lens
     TypedAttributeValueRange
     TypedAttributeValueRange
     (Maybe TypedAttributeValue)
     (Maybe TypedAttributeValue)
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 :: (RangeMode -> f RangeMode)
-> TypedAttributeValueRange -> f TypedAttributeValueRange
typedAttributeValueRange_startMode = (TypedAttributeValueRange -> RangeMode)
-> (TypedAttributeValueRange
    -> RangeMode -> TypedAttributeValueRange)
-> Lens
     TypedAttributeValueRange
     TypedAttributeValueRange
     RangeMode
     RangeMode
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 :: (RangeMode -> f RangeMode)
-> TypedAttributeValueRange -> f TypedAttributeValueRange
typedAttributeValueRange_endMode = (TypedAttributeValueRange -> RangeMode)
-> (TypedAttributeValueRange
    -> RangeMode -> TypedAttributeValueRange)
-> Lens
     TypedAttributeValueRange
     TypedAttributeValueRange
     RangeMode
     RangeMode
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

instance Prelude.NFData TypedAttributeValueRange

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EndValue" Text -> TypedAttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TypedAttributeValue -> Pair)
-> Maybe TypedAttributeValue -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TypedAttributeValue
endValue,
            (Text
"StartValue" Text -> TypedAttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TypedAttributeValue -> Pair)
-> Maybe TypedAttributeValue -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TypedAttributeValue
startValue,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StartMode" Text -> RangeMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RangeMode
startMode),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EndMode" Text -> RangeMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RangeMode
endMode)
          ]
      )