{-# 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.HistogramEntry
-- 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.HistogramEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An entry in a histogram for a statistic. A histogram maps the range of
-- observed values on the X axis, and the prevalence of each value on the Y
-- axis.
--
-- /See:/ 'newHistogramEntry' smart constructor.
data HistogramEntry = HistogramEntry'
  { -- | The prevalence of the entry.
    HistogramEntry -> Maybe Int
count :: Prelude.Maybe Prelude.Int,
    -- | The value of the entry.
    HistogramEntry -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (HistogramEntry -> HistogramEntry -> Bool
(HistogramEntry -> HistogramEntry -> Bool)
-> (HistogramEntry -> HistogramEntry -> Bool) -> Eq HistogramEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HistogramEntry -> HistogramEntry -> Bool
$c/= :: HistogramEntry -> HistogramEntry -> Bool
== :: HistogramEntry -> HistogramEntry -> Bool
$c== :: HistogramEntry -> HistogramEntry -> Bool
Prelude.Eq, ReadPrec [HistogramEntry]
ReadPrec HistogramEntry
Int -> ReadS HistogramEntry
ReadS [HistogramEntry]
(Int -> ReadS HistogramEntry)
-> ReadS [HistogramEntry]
-> ReadPrec HistogramEntry
-> ReadPrec [HistogramEntry]
-> Read HistogramEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HistogramEntry]
$creadListPrec :: ReadPrec [HistogramEntry]
readPrec :: ReadPrec HistogramEntry
$creadPrec :: ReadPrec HistogramEntry
readList :: ReadS [HistogramEntry]
$creadList :: ReadS [HistogramEntry]
readsPrec :: Int -> ReadS HistogramEntry
$creadsPrec :: Int -> ReadS HistogramEntry
Prelude.Read, Int -> HistogramEntry -> ShowS
[HistogramEntry] -> ShowS
HistogramEntry -> String
(Int -> HistogramEntry -> ShowS)
-> (HistogramEntry -> String)
-> ([HistogramEntry] -> ShowS)
-> Show HistogramEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HistogramEntry] -> ShowS
$cshowList :: [HistogramEntry] -> ShowS
show :: HistogramEntry -> String
$cshow :: HistogramEntry -> String
showsPrec :: Int -> HistogramEntry -> ShowS
$cshowsPrec :: Int -> HistogramEntry -> ShowS
Prelude.Show, (forall x. HistogramEntry -> Rep HistogramEntry x)
-> (forall x. Rep HistogramEntry x -> HistogramEntry)
-> Generic HistogramEntry
forall x. Rep HistogramEntry x -> HistogramEntry
forall x. HistogramEntry -> Rep HistogramEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HistogramEntry x -> HistogramEntry
$cfrom :: forall x. HistogramEntry -> Rep HistogramEntry x
Prelude.Generic)

-- |
-- Create a value of 'HistogramEntry' 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:
--
-- 'count', 'histogramEntry_count' - The prevalence of the entry.
--
-- 'value', 'histogramEntry_value' - The value of the entry.
newHistogramEntry ::
  HistogramEntry
newHistogramEntry :: HistogramEntry
newHistogramEntry =
  HistogramEntry' :: Maybe Int -> Maybe Double -> HistogramEntry
HistogramEntry'
    { $sel:count:HistogramEntry' :: Maybe Int
count = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:value:HistogramEntry' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The prevalence of the entry.
histogramEntry_count :: Lens.Lens' HistogramEntry (Prelude.Maybe Prelude.Int)
histogramEntry_count :: (Maybe Int -> f (Maybe Int)) -> HistogramEntry -> f HistogramEntry
histogramEntry_count = (HistogramEntry -> Maybe Int)
-> (HistogramEntry -> Maybe Int -> HistogramEntry)
-> Lens HistogramEntry HistogramEntry (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistogramEntry' {Maybe Int
count :: Maybe Int
$sel:count:HistogramEntry' :: HistogramEntry -> Maybe Int
count} -> Maybe Int
count) (\s :: HistogramEntry
s@HistogramEntry' {} Maybe Int
a -> HistogramEntry
s {$sel:count:HistogramEntry' :: Maybe Int
count = Maybe Int
a} :: HistogramEntry)

-- | The value of the entry.
histogramEntry_value :: Lens.Lens' HistogramEntry (Prelude.Maybe Prelude.Double)
histogramEntry_value :: (Maybe Double -> f (Maybe Double))
-> HistogramEntry -> f HistogramEntry
histogramEntry_value = (HistogramEntry -> Maybe Double)
-> (HistogramEntry -> Maybe Double -> HistogramEntry)
-> Lens HistogramEntry HistogramEntry (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistogramEntry' {Maybe Double
value :: Maybe Double
$sel:value:HistogramEntry' :: HistogramEntry -> Maybe Double
value} -> Maybe Double
value) (\s :: HistogramEntry
s@HistogramEntry' {} Maybe Double
a -> HistogramEntry
s {$sel:value:HistogramEntry' :: Maybe Double
value = Maybe Double
a} :: HistogramEntry)

instance Core.FromJSON HistogramEntry where
  parseJSON :: Value -> Parser HistogramEntry
parseJSON =
    String
-> (Object -> Parser HistogramEntry)
-> Value
-> Parser HistogramEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HistogramEntry"
      ( \Object
x ->
          Maybe Int -> Maybe Double -> HistogramEntry
HistogramEntry'
            (Maybe Int -> Maybe Double -> HistogramEntry)
-> Parser (Maybe Int) -> Parser (Maybe Double -> HistogramEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Count")
            Parser (Maybe Double -> HistogramEntry)
-> Parser (Maybe Double) -> Parser HistogramEntry
forall (f :: * -> *) a b. Applicative f => 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
"Value")
      )

instance Prelude.Hashable HistogramEntry

instance Prelude.NFData HistogramEntry