{-# 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.ObjectAttributeRange
-- 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.ObjectAttributeRange where

import Amazonka.CloudDirectory.Types.AttributeKey
import Amazonka.CloudDirectory.Types.TypedAttributeValueRange
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 attributes.
--
-- /See:/ 'newObjectAttributeRange' smart constructor.
data ObjectAttributeRange = ObjectAttributeRange'
  { -- | The key of the attribute that the attribute range covers.
    ObjectAttributeRange -> Maybe AttributeKey
attributeKey :: Prelude.Maybe AttributeKey,
    -- | The range of attribute values being selected.
    ObjectAttributeRange -> Maybe TypedAttributeValueRange
range :: Prelude.Maybe TypedAttributeValueRange
  }
  deriving (ObjectAttributeRange -> ObjectAttributeRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
$c/= :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
== :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
$c== :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
Prelude.Eq, ReadPrec [ObjectAttributeRange]
ReadPrec ObjectAttributeRange
Int -> ReadS ObjectAttributeRange
ReadS [ObjectAttributeRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ObjectAttributeRange]
$creadListPrec :: ReadPrec [ObjectAttributeRange]
readPrec :: ReadPrec ObjectAttributeRange
$creadPrec :: ReadPrec ObjectAttributeRange
readList :: ReadS [ObjectAttributeRange]
$creadList :: ReadS [ObjectAttributeRange]
readsPrec :: Int -> ReadS ObjectAttributeRange
$creadsPrec :: Int -> ReadS ObjectAttributeRange
Prelude.Read, Int -> ObjectAttributeRange -> ShowS
[ObjectAttributeRange] -> ShowS
ObjectAttributeRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectAttributeRange] -> ShowS
$cshowList :: [ObjectAttributeRange] -> ShowS
show :: ObjectAttributeRange -> String
$cshow :: ObjectAttributeRange -> String
showsPrec :: Int -> ObjectAttributeRange -> ShowS
$cshowsPrec :: Int -> ObjectAttributeRange -> ShowS
Prelude.Show, forall x. Rep ObjectAttributeRange x -> ObjectAttributeRange
forall x. ObjectAttributeRange -> Rep ObjectAttributeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ObjectAttributeRange x -> ObjectAttributeRange
$cfrom :: forall x. ObjectAttributeRange -> Rep ObjectAttributeRange x
Prelude.Generic)

-- |
-- Create a value of 'ObjectAttributeRange' 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:
--
-- 'attributeKey', 'objectAttributeRange_attributeKey' - The key of the attribute that the attribute range covers.
--
-- 'range', 'objectAttributeRange_range' - The range of attribute values being selected.
newObjectAttributeRange ::
  ObjectAttributeRange
newObjectAttributeRange :: ObjectAttributeRange
newObjectAttributeRange =
  ObjectAttributeRange'
    { $sel:attributeKey:ObjectAttributeRange' :: Maybe AttributeKey
attributeKey =
        forall a. Maybe a
Prelude.Nothing,
      $sel:range:ObjectAttributeRange' :: Maybe TypedAttributeValueRange
range = forall a. Maybe a
Prelude.Nothing
    }

-- | The key of the attribute that the attribute range covers.
objectAttributeRange_attributeKey :: Lens.Lens' ObjectAttributeRange (Prelude.Maybe AttributeKey)
objectAttributeRange_attributeKey :: Lens' ObjectAttributeRange (Maybe AttributeKey)
objectAttributeRange_attributeKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectAttributeRange' {Maybe AttributeKey
attributeKey :: Maybe AttributeKey
$sel:attributeKey:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe AttributeKey
attributeKey} -> Maybe AttributeKey
attributeKey) (\s :: ObjectAttributeRange
s@ObjectAttributeRange' {} Maybe AttributeKey
a -> ObjectAttributeRange
s {$sel:attributeKey:ObjectAttributeRange' :: Maybe AttributeKey
attributeKey = Maybe AttributeKey
a} :: ObjectAttributeRange)

-- | The range of attribute values being selected.
objectAttributeRange_range :: Lens.Lens' ObjectAttributeRange (Prelude.Maybe TypedAttributeValueRange)
objectAttributeRange_range :: Lens' ObjectAttributeRange (Maybe TypedAttributeValueRange)
objectAttributeRange_range = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectAttributeRange' {Maybe TypedAttributeValueRange
range :: Maybe TypedAttributeValueRange
$sel:range:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe TypedAttributeValueRange
range} -> Maybe TypedAttributeValueRange
range) (\s :: ObjectAttributeRange
s@ObjectAttributeRange' {} Maybe TypedAttributeValueRange
a -> ObjectAttributeRange
s {$sel:range:ObjectAttributeRange' :: Maybe TypedAttributeValueRange
range = Maybe TypedAttributeValueRange
a} :: ObjectAttributeRange)

instance Prelude.Hashable ObjectAttributeRange where
  hashWithSalt :: Int -> ObjectAttributeRange -> Int
hashWithSalt Int
_salt ObjectAttributeRange' {Maybe AttributeKey
Maybe TypedAttributeValueRange
range :: Maybe TypedAttributeValueRange
attributeKey :: Maybe AttributeKey
$sel:range:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe TypedAttributeValueRange
$sel:attributeKey:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe AttributeKey
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttributeKey
attributeKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TypedAttributeValueRange
range

instance Prelude.NFData ObjectAttributeRange where
  rnf :: ObjectAttributeRange -> ()
rnf ObjectAttributeRange' {Maybe AttributeKey
Maybe TypedAttributeValueRange
range :: Maybe TypedAttributeValueRange
attributeKey :: Maybe AttributeKey
$sel:range:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe TypedAttributeValueRange
$sel:attributeKey:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe AttributeKey
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttributeKey
attributeKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TypedAttributeValueRange
range

instance Data.ToJSON ObjectAttributeRange where
  toJSON :: ObjectAttributeRange -> Value
toJSON ObjectAttributeRange' {Maybe AttributeKey
Maybe TypedAttributeValueRange
range :: Maybe TypedAttributeValueRange
attributeKey :: Maybe AttributeKey
$sel:range:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe TypedAttributeValueRange
$sel:attributeKey:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe AttributeKey
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AttributeKey" 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 AttributeKey
attributeKey,
            (Key
"Range" 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 TypedAttributeValueRange
range
          ]
      )