{-# 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.Rekognition.Types.AgeRange
-- 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.Rekognition.Types.AgeRange 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

-- | Structure containing the estimated age range, in years, for a face.
--
-- Amazon Rekognition estimates an age range for faces detected in the
-- input image. Estimated age ranges can overlap. A face of a 5-year-old
-- might have an estimated range of 4-6, while the face of a 6-year-old
-- might have an estimated range of 4-8.
--
-- /See:/ 'newAgeRange' smart constructor.
data AgeRange = AgeRange'
  { -- | The highest estimated age.
    AgeRange -> Maybe Natural
high :: Prelude.Maybe Prelude.Natural,
    -- | The lowest estimated age.
    AgeRange -> Maybe Natural
low :: Prelude.Maybe Prelude.Natural
  }
  deriving (AgeRange -> AgeRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AgeRange -> AgeRange -> Bool
$c/= :: AgeRange -> AgeRange -> Bool
== :: AgeRange -> AgeRange -> Bool
$c== :: AgeRange -> AgeRange -> Bool
Prelude.Eq, ReadPrec [AgeRange]
ReadPrec AgeRange
Int -> ReadS AgeRange
ReadS [AgeRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AgeRange]
$creadListPrec :: ReadPrec [AgeRange]
readPrec :: ReadPrec AgeRange
$creadPrec :: ReadPrec AgeRange
readList :: ReadS [AgeRange]
$creadList :: ReadS [AgeRange]
readsPrec :: Int -> ReadS AgeRange
$creadsPrec :: Int -> ReadS AgeRange
Prelude.Read, Int -> AgeRange -> ShowS
[AgeRange] -> ShowS
AgeRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AgeRange] -> ShowS
$cshowList :: [AgeRange] -> ShowS
show :: AgeRange -> String
$cshow :: AgeRange -> String
showsPrec :: Int -> AgeRange -> ShowS
$cshowsPrec :: Int -> AgeRange -> ShowS
Prelude.Show, forall x. Rep AgeRange x -> AgeRange
forall x. AgeRange -> Rep AgeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AgeRange x -> AgeRange
$cfrom :: forall x. AgeRange -> Rep AgeRange x
Prelude.Generic)

-- |
-- Create a value of 'AgeRange' 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:
--
-- 'high', 'ageRange_high' - The highest estimated age.
--
-- 'low', 'ageRange_low' - The lowest estimated age.
newAgeRange ::
  AgeRange
newAgeRange :: AgeRange
newAgeRange =
  AgeRange'
    { $sel:high:AgeRange' :: Maybe Natural
high = forall a. Maybe a
Prelude.Nothing,
      $sel:low:AgeRange' :: Maybe Natural
low = forall a. Maybe a
Prelude.Nothing
    }

-- | The highest estimated age.
ageRange_high :: Lens.Lens' AgeRange (Prelude.Maybe Prelude.Natural)
ageRange_high :: Lens' AgeRange (Maybe Natural)
ageRange_high = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AgeRange' {Maybe Natural
high :: Maybe Natural
$sel:high:AgeRange' :: AgeRange -> Maybe Natural
high} -> Maybe Natural
high) (\s :: AgeRange
s@AgeRange' {} Maybe Natural
a -> AgeRange
s {$sel:high:AgeRange' :: Maybe Natural
high = Maybe Natural
a} :: AgeRange)

-- | The lowest estimated age.
ageRange_low :: Lens.Lens' AgeRange (Prelude.Maybe Prelude.Natural)
ageRange_low :: Lens' AgeRange (Maybe Natural)
ageRange_low = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AgeRange' {Maybe Natural
low :: Maybe Natural
$sel:low:AgeRange' :: AgeRange -> Maybe Natural
low} -> Maybe Natural
low) (\s :: AgeRange
s@AgeRange' {} Maybe Natural
a -> AgeRange
s {$sel:low:AgeRange' :: Maybe Natural
low = Maybe Natural
a} :: AgeRange)

instance Data.FromJSON AgeRange where
  parseJSON :: Value -> Parser AgeRange
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AgeRange"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> AgeRange
AgeRange'
            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
"High")
            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
"Low")
      )

instance Prelude.Hashable AgeRange where
  hashWithSalt :: Int -> AgeRange -> Int
hashWithSalt Int
_salt AgeRange' {Maybe Natural
low :: Maybe Natural
high :: Maybe Natural
$sel:low:AgeRange' :: AgeRange -> Maybe Natural
$sel:high:AgeRange' :: AgeRange -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
high
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
low

instance Prelude.NFData AgeRange where
  rnf :: AgeRange -> ()
rnf AgeRange' {Maybe Natural
low :: Maybe Natural
high :: Maybe Natural
$sel:low:AgeRange' :: AgeRange -> Maybe Natural
$sel:high:AgeRange' :: AgeRange -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
high seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
low