{-# 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 #-}
module Amazonka.IotTwinMaker.Types.PropertyValueEntry 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.EntityPropertyReference
import Amazonka.IotTwinMaker.Types.PropertyValue
import qualified Amazonka.Prelude as Prelude
data PropertyValueEntry = PropertyValueEntry'
{
PropertyValueEntry -> Maybe (NonEmpty PropertyValue)
propertyValues :: Prelude.Maybe (Prelude.NonEmpty PropertyValue),
PropertyValueEntry -> EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
}
deriving (PropertyValueEntry -> PropertyValueEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyValueEntry -> PropertyValueEntry -> Bool
$c/= :: PropertyValueEntry -> PropertyValueEntry -> Bool
== :: PropertyValueEntry -> PropertyValueEntry -> Bool
$c== :: PropertyValueEntry -> PropertyValueEntry -> Bool
Prelude.Eq, ReadPrec [PropertyValueEntry]
ReadPrec PropertyValueEntry
Int -> ReadS PropertyValueEntry
ReadS [PropertyValueEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyValueEntry]
$creadListPrec :: ReadPrec [PropertyValueEntry]
readPrec :: ReadPrec PropertyValueEntry
$creadPrec :: ReadPrec PropertyValueEntry
readList :: ReadS [PropertyValueEntry]
$creadList :: ReadS [PropertyValueEntry]
readsPrec :: Int -> ReadS PropertyValueEntry
$creadsPrec :: Int -> ReadS PropertyValueEntry
Prelude.Read, Int -> PropertyValueEntry -> ShowS
[PropertyValueEntry] -> ShowS
PropertyValueEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyValueEntry] -> ShowS
$cshowList :: [PropertyValueEntry] -> ShowS
show :: PropertyValueEntry -> String
$cshow :: PropertyValueEntry -> String
showsPrec :: Int -> PropertyValueEntry -> ShowS
$cshowsPrec :: Int -> PropertyValueEntry -> ShowS
Prelude.Show, forall x. Rep PropertyValueEntry x -> PropertyValueEntry
forall x. PropertyValueEntry -> Rep PropertyValueEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyValueEntry x -> PropertyValueEntry
$cfrom :: forall x. PropertyValueEntry -> Rep PropertyValueEntry x
Prelude.Generic)
newPropertyValueEntry ::
EntityPropertyReference ->
PropertyValueEntry
newPropertyValueEntry :: EntityPropertyReference -> PropertyValueEntry
newPropertyValueEntry EntityPropertyReference
pEntityPropertyReference_ =
PropertyValueEntry'
{ $sel:propertyValues:PropertyValueEntry' :: Maybe (NonEmpty PropertyValue)
propertyValues =
forall a. Maybe a
Prelude.Nothing,
$sel:entityPropertyReference:PropertyValueEntry' :: EntityPropertyReference
entityPropertyReference = EntityPropertyReference
pEntityPropertyReference_
}
propertyValueEntry_propertyValues :: Lens.Lens' PropertyValueEntry (Prelude.Maybe (Prelude.NonEmpty PropertyValue))
propertyValueEntry_propertyValues :: Lens' PropertyValueEntry (Maybe (NonEmpty PropertyValue))
propertyValueEntry_propertyValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyValueEntry' {Maybe (NonEmpty PropertyValue)
propertyValues :: Maybe (NonEmpty PropertyValue)
$sel:propertyValues:PropertyValueEntry' :: PropertyValueEntry -> Maybe (NonEmpty PropertyValue)
propertyValues} -> Maybe (NonEmpty PropertyValue)
propertyValues) (\s :: PropertyValueEntry
s@PropertyValueEntry' {} Maybe (NonEmpty PropertyValue)
a -> PropertyValueEntry
s {$sel:propertyValues:PropertyValueEntry' :: Maybe (NonEmpty PropertyValue)
propertyValues = Maybe (NonEmpty PropertyValue)
a} :: PropertyValueEntry) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
propertyValueEntry_entityPropertyReference :: Lens.Lens' PropertyValueEntry EntityPropertyReference
propertyValueEntry_entityPropertyReference :: Lens' PropertyValueEntry EntityPropertyReference
propertyValueEntry_entityPropertyReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyValueEntry' {EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
$sel:entityPropertyReference:PropertyValueEntry' :: PropertyValueEntry -> EntityPropertyReference
entityPropertyReference} -> EntityPropertyReference
entityPropertyReference) (\s :: PropertyValueEntry
s@PropertyValueEntry' {} EntityPropertyReference
a -> PropertyValueEntry
s {$sel:entityPropertyReference:PropertyValueEntry' :: EntityPropertyReference
entityPropertyReference = EntityPropertyReference
a} :: PropertyValueEntry)
instance Data.FromJSON PropertyValueEntry where
parseJSON :: Value -> Parser PropertyValueEntry
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"PropertyValueEntry"
( \Object
x ->
Maybe (NonEmpty PropertyValue)
-> EntityPropertyReference -> PropertyValueEntry
PropertyValueEntry'
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
"propertyValues")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"entityPropertyReference")
)
instance Prelude.Hashable PropertyValueEntry where
hashWithSalt :: Int -> PropertyValueEntry -> Int
hashWithSalt Int
_salt PropertyValueEntry' {Maybe (NonEmpty PropertyValue)
EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
propertyValues :: Maybe (NonEmpty PropertyValue)
$sel:entityPropertyReference:PropertyValueEntry' :: PropertyValueEntry -> EntityPropertyReference
$sel:propertyValues:PropertyValueEntry' :: PropertyValueEntry -> Maybe (NonEmpty PropertyValue)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty PropertyValue)
propertyValues
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EntityPropertyReference
entityPropertyReference
instance Prelude.NFData PropertyValueEntry where
rnf :: PropertyValueEntry -> ()
rnf PropertyValueEntry' {Maybe (NonEmpty PropertyValue)
EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
propertyValues :: Maybe (NonEmpty PropertyValue)
$sel:entityPropertyReference:PropertyValueEntry' :: PropertyValueEntry -> EntityPropertyReference
$sel:propertyValues:PropertyValueEntry' :: PropertyValueEntry -> Maybe (NonEmpty PropertyValue)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty PropertyValue)
propertyValues
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EntityPropertyReference
entityPropertyReference
instance Data.ToJSON PropertyValueEntry where
toJSON :: PropertyValueEntry -> Value
toJSON PropertyValueEntry' {Maybe (NonEmpty PropertyValue)
EntityPropertyReference
entityPropertyReference :: EntityPropertyReference
propertyValues :: Maybe (NonEmpty PropertyValue)
$sel:entityPropertyReference:PropertyValueEntry' :: PropertyValueEntry -> EntityPropertyReference
$sel:propertyValues:PropertyValueEntry' :: PropertyValueEntry -> Maybe (NonEmpty PropertyValue)
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"propertyValues" 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 (NonEmpty PropertyValue)
propertyValues,
forall a. a -> Maybe a
Prelude.Just
( Key
"entityPropertyReference"
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EntityPropertyReference
entityPropertyReference
)
]
)