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

-- | 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
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]
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
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. 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'
    { $sel:count:HistogramEntry' :: Maybe Int
count = forall a. Maybe a
Prelude.Nothing,
      $sel:value:HistogramEntry' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The prevalence of the entry.
histogramEntry_count :: Lens.Lens' HistogramEntry (Prelude.Maybe Prelude.Int)
histogramEntry_count :: Lens' HistogramEntry (Maybe Int)
histogramEntry_count = 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 :: Lens' HistogramEntry (Maybe Double)
histogramEntry_value = 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 Data.FromJSON HistogramEntry where
  parseJSON :: Value -> Parser HistogramEntry
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HistogramEntry"
      ( \Object
x ->
          Maybe Int -> Maybe Double -> HistogramEntry
HistogramEntry'
            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
"Count")
            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
"Value")
      )

instance Prelude.Hashable HistogramEntry where
  hashWithSalt :: Int -> HistogramEntry -> Int
hashWithSalt Int
_salt HistogramEntry' {Maybe Double
Maybe Int
value :: Maybe Double
count :: Maybe Int
$sel:value:HistogramEntry' :: HistogramEntry -> Maybe Double
$sel:count:HistogramEntry' :: HistogramEntry -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
count
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
value

instance Prelude.NFData HistogramEntry where
  rnf :: HistogramEntry -> ()
rnf HistogramEntry' {Maybe Double
Maybe Int
value :: Maybe Double
count :: Maybe Int
$sel:value:HistogramEntry' :: HistogramEntry -> Maybe Double
$sel:count:HistogramEntry' :: HistogramEntry -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
count seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
value