{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.XRay.Types.AnnotationValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Number annotation.
    AnnotationValue -> Maybe Double
numberValue :: Prelude.Maybe Prelude.Double,
    -- | Value for a String annotation.
    AnnotationValue -> Maybe Text
stringValue :: Prelude.Maybe Prelude.Text,
    -- | Value for a Boolean annotation.
    AnnotationValue -> Maybe Bool
booleanValue :: Prelude.Maybe Prelude.Bool
  }
  deriving (AnnotationValue -> AnnotationValue -> Bool
(AnnotationValue -> AnnotationValue -> Bool)
-> (AnnotationValue -> AnnotationValue -> Bool)
-> Eq AnnotationValue
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]
(Int -> ReadS AnnotationValue)
-> ReadS [AnnotationValue]
-> ReadPrec AnnotationValue
-> ReadPrec [AnnotationValue]
-> Read 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
(Int -> AnnotationValue -> ShowS)
-> (AnnotationValue -> String)
-> ([AnnotationValue] -> ShowS)
-> Show AnnotationValue
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. AnnotationValue -> Rep AnnotationValue x)
-> (forall x. Rep AnnotationValue x -> AnnotationValue)
-> Generic AnnotationValue
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:
--
-- 'numberValue', 'annotationValue_numberValue' - Value for a Number annotation.
--
-- 'stringValue', 'annotationValue_stringValue' - Value for a String annotation.
--
-- 'booleanValue', 'annotationValue_booleanValue' - Value for a Boolean annotation.
newAnnotationValue ::
  AnnotationValue
newAnnotationValue :: AnnotationValue
newAnnotationValue =
  AnnotationValue' :: Maybe Double -> Maybe Text -> Maybe Bool -> AnnotationValue
AnnotationValue'
    { $sel:numberValue:AnnotationValue' :: Maybe Double
numberValue = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:stringValue:AnnotationValue' :: Maybe Text
stringValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:booleanValue:AnnotationValue' :: Maybe Bool
booleanValue = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Value for a Number annotation.
annotationValue_numberValue :: Lens.Lens' AnnotationValue (Prelude.Maybe Prelude.Double)
annotationValue_numberValue :: (Maybe Double -> f (Maybe Double))
-> AnnotationValue -> f AnnotationValue
annotationValue_numberValue = (AnnotationValue -> Maybe Double)
-> (AnnotationValue -> Maybe Double -> AnnotationValue)
-> Lens
     AnnotationValue AnnotationValue (Maybe Double) (Maybe Double)
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 :: (Maybe Text -> f (Maybe Text))
-> AnnotationValue -> f AnnotationValue
annotationValue_stringValue = (AnnotationValue -> Maybe Text)
-> (AnnotationValue -> Maybe Text -> AnnotationValue)
-> Lens AnnotationValue AnnotationValue (Maybe Text) (Maybe Text)
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)

-- | Value for a Boolean annotation.
annotationValue_booleanValue :: Lens.Lens' AnnotationValue (Prelude.Maybe Prelude.Bool)
annotationValue_booleanValue :: (Maybe Bool -> f (Maybe Bool))
-> AnnotationValue -> f AnnotationValue
annotationValue_booleanValue = (AnnotationValue -> Maybe Bool)
-> (AnnotationValue -> Maybe Bool -> AnnotationValue)
-> Lens AnnotationValue AnnotationValue (Maybe Bool) (Maybe Bool)
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)

instance Core.FromJSON AnnotationValue where
  parseJSON :: Value -> Parser AnnotationValue
parseJSON =
    String
-> (Object -> Parser AnnotationValue)
-> Value
-> Parser AnnotationValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AnnotationValue"
      ( \Object
x ->
          Maybe Double -> Maybe Text -> Maybe Bool -> AnnotationValue
AnnotationValue'
            (Maybe Double -> Maybe Text -> Maybe Bool -> AnnotationValue)
-> Parser (Maybe Double)
-> Parser (Maybe Text -> Maybe Bool -> AnnotationValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumberValue")
            Parser (Maybe Text -> Maybe Bool -> AnnotationValue)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> AnnotationValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StringValue")
            Parser (Maybe Bool -> AnnotationValue)
-> Parser (Maybe Bool) -> Parser AnnotationValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BooleanValue")
      )

instance Prelude.Hashable AnnotationValue

instance Prelude.NFData AnnotationValue