{-# 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.LookoutEquipment.Types.CountPercent
-- 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.LookoutEquipment.Types.CountPercent 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

-- | Entity that comprises information of count and percentage.
--
-- /See:/ 'newCountPercent' smart constructor.
data CountPercent = CountPercent'
  { -- | Indicates the count of occurences of the given statistic.
    CountPercent -> Int
count :: Prelude.Int,
    -- | Indicates the percentage of occurances of the given statistic.
    CountPercent -> Double
percentage :: Prelude.Double
  }
  deriving (CountPercent -> CountPercent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CountPercent -> CountPercent -> Bool
$c/= :: CountPercent -> CountPercent -> Bool
== :: CountPercent -> CountPercent -> Bool
$c== :: CountPercent -> CountPercent -> Bool
Prelude.Eq, ReadPrec [CountPercent]
ReadPrec CountPercent
Int -> ReadS CountPercent
ReadS [CountPercent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CountPercent]
$creadListPrec :: ReadPrec [CountPercent]
readPrec :: ReadPrec CountPercent
$creadPrec :: ReadPrec CountPercent
readList :: ReadS [CountPercent]
$creadList :: ReadS [CountPercent]
readsPrec :: Int -> ReadS CountPercent
$creadsPrec :: Int -> ReadS CountPercent
Prelude.Read, Int -> CountPercent -> ShowS
[CountPercent] -> ShowS
CountPercent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CountPercent] -> ShowS
$cshowList :: [CountPercent] -> ShowS
show :: CountPercent -> String
$cshow :: CountPercent -> String
showsPrec :: Int -> CountPercent -> ShowS
$cshowsPrec :: Int -> CountPercent -> ShowS
Prelude.Show, forall x. Rep CountPercent x -> CountPercent
forall x. CountPercent -> Rep CountPercent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CountPercent x -> CountPercent
$cfrom :: forall x. CountPercent -> Rep CountPercent x
Prelude.Generic)

-- |
-- Create a value of 'CountPercent' 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', 'countPercent_count' - Indicates the count of occurences of the given statistic.
--
-- 'percentage', 'countPercent_percentage' - Indicates the percentage of occurances of the given statistic.
newCountPercent ::
  -- | 'count'
  Prelude.Int ->
  -- | 'percentage'
  Prelude.Double ->
  CountPercent
newCountPercent :: Int -> Double -> CountPercent
newCountPercent Int
pCount_ Double
pPercentage_ =
  CountPercent'
    { $sel:count:CountPercent' :: Int
count = Int
pCount_,
      $sel:percentage:CountPercent' :: Double
percentage = Double
pPercentage_
    }

-- | Indicates the count of occurences of the given statistic.
countPercent_count :: Lens.Lens' CountPercent Prelude.Int
countPercent_count :: Lens' CountPercent Int
countPercent_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CountPercent' {Int
count :: Int
$sel:count:CountPercent' :: CountPercent -> Int
count} -> Int
count) (\s :: CountPercent
s@CountPercent' {} Int
a -> CountPercent
s {$sel:count:CountPercent' :: Int
count = Int
a} :: CountPercent)

-- | Indicates the percentage of occurances of the given statistic.
countPercent_percentage :: Lens.Lens' CountPercent Prelude.Double
countPercent_percentage :: Lens' CountPercent Double
countPercent_percentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CountPercent' {Double
percentage :: Double
$sel:percentage:CountPercent' :: CountPercent -> Double
percentage} -> Double
percentage) (\s :: CountPercent
s@CountPercent' {} Double
a -> CountPercent
s {$sel:percentage:CountPercent' :: Double
percentage = Double
a} :: CountPercent)

instance Data.FromJSON CountPercent where
  parseJSON :: Value -> Parser CountPercent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CountPercent"
      ( \Object
x ->
          Int -> Double -> CountPercent
CountPercent'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"Percentage")
      )

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

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