{-# 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.IoT.Types.AssetPropertyVariant
-- 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.IoT.Types.AssetPropertyVariant where

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

-- | Contains an asset property value (of a single type).
--
-- /See:/ 'newAssetPropertyVariant' smart constructor.
data AssetPropertyVariant = AssetPropertyVariant'
  { -- | Optional. A string that contains the boolean value (@true@ or @false@)
    -- of the value entry. Accepts substitution templates.
    AssetPropertyVariant -> Maybe Text
booleanValue :: Prelude.Maybe Prelude.Text,
    -- | Optional. A string that contains the double value of the value entry.
    -- Accepts substitution templates.
    AssetPropertyVariant -> Maybe Text
doubleValue :: Prelude.Maybe Prelude.Text,
    -- | Optional. A string that contains the integer value of the value entry.
    -- Accepts substitution templates.
    AssetPropertyVariant -> Maybe Text
integerValue :: Prelude.Maybe Prelude.Text,
    -- | Optional. The string value of the value entry. Accepts substitution
    -- templates.
    AssetPropertyVariant -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text
  }
  deriving (AssetPropertyVariant -> AssetPropertyVariant -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetPropertyVariant -> AssetPropertyVariant -> Bool
$c/= :: AssetPropertyVariant -> AssetPropertyVariant -> Bool
== :: AssetPropertyVariant -> AssetPropertyVariant -> Bool
$c== :: AssetPropertyVariant -> AssetPropertyVariant -> Bool
Prelude.Eq, ReadPrec [AssetPropertyVariant]
ReadPrec AssetPropertyVariant
Int -> ReadS AssetPropertyVariant
ReadS [AssetPropertyVariant]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetPropertyVariant]
$creadListPrec :: ReadPrec [AssetPropertyVariant]
readPrec :: ReadPrec AssetPropertyVariant
$creadPrec :: ReadPrec AssetPropertyVariant
readList :: ReadS [AssetPropertyVariant]
$creadList :: ReadS [AssetPropertyVariant]
readsPrec :: Int -> ReadS AssetPropertyVariant
$creadsPrec :: Int -> ReadS AssetPropertyVariant
Prelude.Read, Int -> AssetPropertyVariant -> ShowS
[AssetPropertyVariant] -> ShowS
AssetPropertyVariant -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetPropertyVariant] -> ShowS
$cshowList :: [AssetPropertyVariant] -> ShowS
show :: AssetPropertyVariant -> String
$cshow :: AssetPropertyVariant -> String
showsPrec :: Int -> AssetPropertyVariant -> ShowS
$cshowsPrec :: Int -> AssetPropertyVariant -> ShowS
Prelude.Show, forall x. Rep AssetPropertyVariant x -> AssetPropertyVariant
forall x. AssetPropertyVariant -> Rep AssetPropertyVariant x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetPropertyVariant x -> AssetPropertyVariant
$cfrom :: forall x. AssetPropertyVariant -> Rep AssetPropertyVariant x
Prelude.Generic)

-- |
-- Create a value of 'AssetPropertyVariant' 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:
--
-- 'booleanValue', 'assetPropertyVariant_booleanValue' - Optional. A string that contains the boolean value (@true@ or @false@)
-- of the value entry. Accepts substitution templates.
--
-- 'doubleValue', 'assetPropertyVariant_doubleValue' - Optional. A string that contains the double value of the value entry.
-- Accepts substitution templates.
--
-- 'integerValue', 'assetPropertyVariant_integerValue' - Optional. A string that contains the integer value of the value entry.
-- Accepts substitution templates.
--
-- 'stringValue', 'assetPropertyVariant_stringValue' - Optional. The string value of the value entry. Accepts substitution
-- templates.
newAssetPropertyVariant ::
  AssetPropertyVariant
newAssetPropertyVariant :: AssetPropertyVariant
newAssetPropertyVariant =
  AssetPropertyVariant'
    { $sel:booleanValue:AssetPropertyVariant' :: Maybe Text
booleanValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:doubleValue:AssetPropertyVariant' :: Maybe Text
doubleValue = forall a. Maybe a
Prelude.Nothing,
      $sel:integerValue:AssetPropertyVariant' :: Maybe Text
integerValue = forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:AssetPropertyVariant' :: Maybe Text
stringValue = forall a. Maybe a
Prelude.Nothing
    }

-- | Optional. A string that contains the boolean value (@true@ or @false@)
-- of the value entry. Accepts substitution templates.
assetPropertyVariant_booleanValue :: Lens.Lens' AssetPropertyVariant (Prelude.Maybe Prelude.Text)
assetPropertyVariant_booleanValue :: Lens' AssetPropertyVariant (Maybe Text)
assetPropertyVariant_booleanValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetPropertyVariant' {Maybe Text
booleanValue :: Maybe Text
$sel:booleanValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
booleanValue} -> Maybe Text
booleanValue) (\s :: AssetPropertyVariant
s@AssetPropertyVariant' {} Maybe Text
a -> AssetPropertyVariant
s {$sel:booleanValue:AssetPropertyVariant' :: Maybe Text
booleanValue = Maybe Text
a} :: AssetPropertyVariant)

-- | Optional. A string that contains the double value of the value entry.
-- Accepts substitution templates.
assetPropertyVariant_doubleValue :: Lens.Lens' AssetPropertyVariant (Prelude.Maybe Prelude.Text)
assetPropertyVariant_doubleValue :: Lens' AssetPropertyVariant (Maybe Text)
assetPropertyVariant_doubleValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetPropertyVariant' {Maybe Text
doubleValue :: Maybe Text
$sel:doubleValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
doubleValue} -> Maybe Text
doubleValue) (\s :: AssetPropertyVariant
s@AssetPropertyVariant' {} Maybe Text
a -> AssetPropertyVariant
s {$sel:doubleValue:AssetPropertyVariant' :: Maybe Text
doubleValue = Maybe Text
a} :: AssetPropertyVariant)

-- | Optional. A string that contains the integer value of the value entry.
-- Accepts substitution templates.
assetPropertyVariant_integerValue :: Lens.Lens' AssetPropertyVariant (Prelude.Maybe Prelude.Text)
assetPropertyVariant_integerValue :: Lens' AssetPropertyVariant (Maybe Text)
assetPropertyVariant_integerValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetPropertyVariant' {Maybe Text
integerValue :: Maybe Text
$sel:integerValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
integerValue} -> Maybe Text
integerValue) (\s :: AssetPropertyVariant
s@AssetPropertyVariant' {} Maybe Text
a -> AssetPropertyVariant
s {$sel:integerValue:AssetPropertyVariant' :: Maybe Text
integerValue = Maybe Text
a} :: AssetPropertyVariant)

-- | Optional. The string value of the value entry. Accepts substitution
-- templates.
assetPropertyVariant_stringValue :: Lens.Lens' AssetPropertyVariant (Prelude.Maybe Prelude.Text)
assetPropertyVariant_stringValue :: Lens' AssetPropertyVariant (Maybe Text)
assetPropertyVariant_stringValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetPropertyVariant' {Maybe Text
stringValue :: Maybe Text
$sel:stringValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
stringValue} -> Maybe Text
stringValue) (\s :: AssetPropertyVariant
s@AssetPropertyVariant' {} Maybe Text
a -> AssetPropertyVariant
s {$sel:stringValue:AssetPropertyVariant' :: Maybe Text
stringValue = Maybe Text
a} :: AssetPropertyVariant)

instance Data.FromJSON AssetPropertyVariant where
  parseJSON :: Value -> Parser AssetPropertyVariant
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssetPropertyVariant"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> AssetPropertyVariant
AssetPropertyVariant'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"booleanValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"doubleValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"integerValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"stringValue")
      )

instance Prelude.Hashable AssetPropertyVariant where
  hashWithSalt :: Int -> AssetPropertyVariant -> Int
hashWithSalt Int
_salt AssetPropertyVariant' {Maybe Text
stringValue :: Maybe Text
integerValue :: Maybe Text
doubleValue :: Maybe Text
booleanValue :: Maybe Text
$sel:stringValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:integerValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:doubleValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:booleanValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
booleanValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
doubleValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
integerValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stringValue

instance Prelude.NFData AssetPropertyVariant where
  rnf :: AssetPropertyVariant -> ()
rnf AssetPropertyVariant' {Maybe Text
stringValue :: Maybe Text
integerValue :: Maybe Text
doubleValue :: Maybe Text
booleanValue :: Maybe Text
$sel:stringValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:integerValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:doubleValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:booleanValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
booleanValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
doubleValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
integerValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stringValue

instance Data.ToJSON AssetPropertyVariant where
  toJSON :: AssetPropertyVariant -> Value
toJSON AssetPropertyVariant' {Maybe Text
stringValue :: Maybe Text
integerValue :: Maybe Text
doubleValue :: Maybe Text
booleanValue :: Maybe Text
$sel:stringValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:integerValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:doubleValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
$sel:booleanValue:AssetPropertyVariant' :: AssetPropertyVariant -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"booleanValue" 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
booleanValue,
            (Key
"doubleValue" 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
doubleValue,
            (Key
"integerValue" 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
integerValue,
            (Key
"stringValue" 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
stringValue
          ]
      )