{-# 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.XRay.Types.AnnotationValue
-- 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.XRay.Types.AnnotationValue 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

-- | Value of a segment annotation. Has one of three value types: Number,
-- Boolean, or String.
--
-- /See:/ 'newAnnotationValue' smart constructor.
data AnnotationValue = AnnotationValue'
  { -- | Value for a Boolean annotation.
    AnnotationValue -> Maybe Bool
booleanValue :: Prelude.Maybe Prelude.Bool,
    -- | Value for a Number annotation.
    AnnotationValue -> Maybe Double
numberValue :: Prelude.Maybe Prelude.Double,
    -- | Value for a String annotation.
    AnnotationValue -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text
  }
  deriving (AnnotationValue -> AnnotationValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnnotationValue -> AnnotationValue -> Bool
$c/= :: AnnotationValue -> AnnotationValue -> Bool
== :: AnnotationValue -> AnnotationValue -> Bool
$c== :: AnnotationValue -> AnnotationValue -> Bool
Prelude.Eq, ReadPrec [AnnotationValue]
ReadPrec AnnotationValue
Int -> ReadS AnnotationValue
ReadS [AnnotationValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnnotationValue]
$creadListPrec :: ReadPrec [AnnotationValue]
readPrec :: ReadPrec AnnotationValue
$creadPrec :: ReadPrec AnnotationValue
readList :: ReadS [AnnotationValue]
$creadList :: ReadS [AnnotationValue]
readsPrec :: Int -> ReadS AnnotationValue
$creadsPrec :: Int -> ReadS AnnotationValue
Prelude.Read, Int -> AnnotationValue -> ShowS
[AnnotationValue] -> ShowS
AnnotationValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnnotationValue] -> ShowS
$cshowList :: [AnnotationValue] -> ShowS
show :: AnnotationValue -> String
$cshow :: AnnotationValue -> String
showsPrec :: Int -> AnnotationValue -> ShowS
$cshowsPrec :: Int -> AnnotationValue -> ShowS
Prelude.Show, forall x. Rep AnnotationValue x -> AnnotationValue
forall x. AnnotationValue -> Rep AnnotationValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnnotationValue x -> AnnotationValue
$cfrom :: forall x. AnnotationValue -> Rep AnnotationValue x
Prelude.Generic)

-- |
-- Create a value of 'AnnotationValue' 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', 'annotationValue_booleanValue' - Value for a Boolean annotation.
--
-- 'numberValue', 'annotationValue_numberValue' - Value for a Number annotation.
--
-- 'stringValue', 'annotationValue_stringValue' - Value for a String annotation.
newAnnotationValue ::
  AnnotationValue
newAnnotationValue :: AnnotationValue
newAnnotationValue =
  AnnotationValue'
    { $sel:booleanValue:AnnotationValue' :: Maybe Bool
booleanValue = forall a. Maybe a
Prelude.Nothing,
      $sel:numberValue:AnnotationValue' :: Maybe Double
numberValue = forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:AnnotationValue' :: Maybe Text
stringValue = forall a. Maybe a
Prelude.Nothing
    }

-- | Value for a Boolean annotation.
annotationValue_booleanValue :: Lens.Lens' AnnotationValue (Prelude.Maybe Prelude.Bool)
annotationValue_booleanValue :: Lens' AnnotationValue (Maybe Bool)
annotationValue_booleanValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnnotationValue' {Maybe Bool
booleanValue :: Maybe Bool
$sel:booleanValue:AnnotationValue' :: AnnotationValue -> Maybe Bool
booleanValue} -> Maybe Bool
booleanValue) (\s :: AnnotationValue
s@AnnotationValue' {} Maybe Bool
a -> AnnotationValue
s {$sel:booleanValue:AnnotationValue' :: Maybe Bool
booleanValue = Maybe Bool
a} :: AnnotationValue)

-- | Value for a Number annotation.
annotationValue_numberValue :: Lens.Lens' AnnotationValue (Prelude.Maybe Prelude.Double)
annotationValue_numberValue :: Lens' AnnotationValue (Maybe Double)
annotationValue_numberValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnnotationValue' {Maybe Double
numberValue :: Maybe Double
$sel:numberValue:AnnotationValue' :: AnnotationValue -> Maybe Double
numberValue} -> Maybe Double
numberValue) (\s :: AnnotationValue
s@AnnotationValue' {} Maybe Double
a -> AnnotationValue
s {$sel:numberValue:AnnotationValue' :: Maybe Double
numberValue = Maybe Double
a} :: AnnotationValue)

-- | Value for a String annotation.
annotationValue_stringValue :: Lens.Lens' AnnotationValue (Prelude.Maybe Prelude.Text)
annotationValue_stringValue :: Lens' AnnotationValue (Maybe Text)
annotationValue_stringValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnnotationValue' {Maybe Text
stringValue :: Maybe Text
$sel:stringValue:AnnotationValue' :: AnnotationValue -> Maybe Text
stringValue} -> Maybe Text
stringValue) (\s :: AnnotationValue
s@AnnotationValue' {} Maybe Text
a -> AnnotationValue
s {$sel:stringValue:AnnotationValue' :: Maybe Text
stringValue = Maybe Text
a} :: AnnotationValue)

instance Data.FromJSON AnnotationValue where
  parseJSON :: Value -> Parser AnnotationValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AnnotationValue"
      ( \Object
x ->
          Maybe Bool -> Maybe Double -> Maybe Text -> AnnotationValue
AnnotationValue'
            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
"NumberValue")
            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 AnnotationValue where
  hashWithSalt :: Int -> AnnotationValue -> Int
hashWithSalt Int
_salt AnnotationValue' {Maybe Bool
Maybe Double
Maybe Text
stringValue :: Maybe Text
numberValue :: Maybe Double
booleanValue :: Maybe Bool
$sel:stringValue:AnnotationValue' :: AnnotationValue -> Maybe Text
$sel:numberValue:AnnotationValue' :: AnnotationValue -> Maybe Double
$sel:booleanValue:AnnotationValue' :: AnnotationValue -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
booleanValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
numberValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stringValue

instance Prelude.NFData AnnotationValue where
  rnf :: AnnotationValue -> ()
rnf AnnotationValue' {Maybe Bool
Maybe Double
Maybe Text
stringValue :: Maybe Text
numberValue :: Maybe Double
booleanValue :: Maybe Bool
$sel:stringValue:AnnotationValue' :: AnnotationValue -> Maybe Text
$sel:numberValue:AnnotationValue' :: AnnotationValue -> Maybe Double
$sel:booleanValue:AnnotationValue' :: AnnotationValue -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
booleanValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
numberValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stringValue