{-# 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.IotTwinMaker.Types.PropertyLatestValue
-- 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.IotTwinMaker.Types.PropertyLatestValue 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.DataValue
import Amazonka.IotTwinMaker.Types.EntityPropertyReference
import qualified Amazonka.Prelude as Prelude

-- | The latest value of the property.
--
-- /See:/ 'newPropertyLatestValue' smart constructor.
data PropertyLatestValue = PropertyLatestValue'
  { -- | The value of the property.
    PropertyLatestValue -> Maybe DataValue
propertyValue :: Prelude.Maybe DataValue,
    -- | An object that specifies information about a property.>
    PropertyLatestValue -> EntityPropertyReference
propertyReference :: EntityPropertyReference
  }
  deriving (PropertyLatestValue -> PropertyLatestValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyLatestValue -> PropertyLatestValue -> Bool
$c/= :: PropertyLatestValue -> PropertyLatestValue -> Bool
== :: PropertyLatestValue -> PropertyLatestValue -> Bool
$c== :: PropertyLatestValue -> PropertyLatestValue -> Bool
Prelude.Eq, ReadPrec [PropertyLatestValue]
ReadPrec PropertyLatestValue
Int -> ReadS PropertyLatestValue
ReadS [PropertyLatestValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyLatestValue]
$creadListPrec :: ReadPrec [PropertyLatestValue]
readPrec :: ReadPrec PropertyLatestValue
$creadPrec :: ReadPrec PropertyLatestValue
readList :: ReadS [PropertyLatestValue]
$creadList :: ReadS [PropertyLatestValue]
readsPrec :: Int -> ReadS PropertyLatestValue
$creadsPrec :: Int -> ReadS PropertyLatestValue
Prelude.Read, Int -> PropertyLatestValue -> ShowS
[PropertyLatestValue] -> ShowS
PropertyLatestValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyLatestValue] -> ShowS
$cshowList :: [PropertyLatestValue] -> ShowS
show :: PropertyLatestValue -> String
$cshow :: PropertyLatestValue -> String
showsPrec :: Int -> PropertyLatestValue -> ShowS
$cshowsPrec :: Int -> PropertyLatestValue -> ShowS
Prelude.Show, forall x. Rep PropertyLatestValue x -> PropertyLatestValue
forall x. PropertyLatestValue -> Rep PropertyLatestValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyLatestValue x -> PropertyLatestValue
$cfrom :: forall x. PropertyLatestValue -> Rep PropertyLatestValue x
Prelude.Generic)

-- |
-- Create a value of 'PropertyLatestValue' 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:
--
-- 'propertyValue', 'propertyLatestValue_propertyValue' - The value of the property.
--
-- 'propertyReference', 'propertyLatestValue_propertyReference' - An object that specifies information about a property.>
newPropertyLatestValue ::
  -- | 'propertyReference'
  EntityPropertyReference ->
  PropertyLatestValue
newPropertyLatestValue :: EntityPropertyReference -> PropertyLatestValue
newPropertyLatestValue EntityPropertyReference
pPropertyReference_ =
  PropertyLatestValue'
    { $sel:propertyValue:PropertyLatestValue' :: Maybe DataValue
propertyValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:propertyReference:PropertyLatestValue' :: EntityPropertyReference
propertyReference = EntityPropertyReference
pPropertyReference_
    }

-- | The value of the property.
propertyLatestValue_propertyValue :: Lens.Lens' PropertyLatestValue (Prelude.Maybe DataValue)
propertyLatestValue_propertyValue :: Lens' PropertyLatestValue (Maybe DataValue)
propertyLatestValue_propertyValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyLatestValue' {Maybe DataValue
propertyValue :: Maybe DataValue
$sel:propertyValue:PropertyLatestValue' :: PropertyLatestValue -> Maybe DataValue
propertyValue} -> Maybe DataValue
propertyValue) (\s :: PropertyLatestValue
s@PropertyLatestValue' {} Maybe DataValue
a -> PropertyLatestValue
s {$sel:propertyValue:PropertyLatestValue' :: Maybe DataValue
propertyValue = Maybe DataValue
a} :: PropertyLatestValue)

-- | An object that specifies information about a property.>
propertyLatestValue_propertyReference :: Lens.Lens' PropertyLatestValue EntityPropertyReference
propertyLatestValue_propertyReference :: Lens' PropertyLatestValue EntityPropertyReference
propertyLatestValue_propertyReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyLatestValue' {EntityPropertyReference
propertyReference :: EntityPropertyReference
$sel:propertyReference:PropertyLatestValue' :: PropertyLatestValue -> EntityPropertyReference
propertyReference} -> EntityPropertyReference
propertyReference) (\s :: PropertyLatestValue
s@PropertyLatestValue' {} EntityPropertyReference
a -> PropertyLatestValue
s {$sel:propertyReference:PropertyLatestValue' :: EntityPropertyReference
propertyReference = EntityPropertyReference
a} :: PropertyLatestValue)

instance Data.FromJSON PropertyLatestValue where
  parseJSON :: Value -> Parser PropertyLatestValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PropertyLatestValue"
      ( \Object
x ->
          Maybe DataValue -> EntityPropertyReference -> PropertyLatestValue
PropertyLatestValue'
            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
"propertyValue")
            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
"propertyReference")
      )

instance Prelude.Hashable PropertyLatestValue where
  hashWithSalt :: Int -> PropertyLatestValue -> Int
hashWithSalt Int
_salt PropertyLatestValue' {Maybe DataValue
EntityPropertyReference
propertyReference :: EntityPropertyReference
propertyValue :: Maybe DataValue
$sel:propertyReference:PropertyLatestValue' :: PropertyLatestValue -> EntityPropertyReference
$sel:propertyValue:PropertyLatestValue' :: PropertyLatestValue -> Maybe DataValue
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DataValue
propertyValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EntityPropertyReference
propertyReference

instance Prelude.NFData PropertyLatestValue where
  rnf :: PropertyLatestValue -> ()
rnf PropertyLatestValue' {Maybe DataValue
EntityPropertyReference
propertyReference :: EntityPropertyReference
propertyValue :: Maybe DataValue
$sel:propertyReference:PropertyLatestValue' :: PropertyLatestValue -> EntityPropertyReference
$sel:propertyValue:PropertyLatestValue' :: PropertyLatestValue -> Maybe DataValue
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DataValue
propertyValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EntityPropertyReference
propertyReference