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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 lowest estimated age.
    AgeRange -> Maybe Natural
low :: Prelude.Maybe Prelude.Natural,
    -- | The highest estimated age.
    AgeRange -> Maybe Natural
high :: Prelude.Maybe Prelude.Natural
  }
  deriving (AgeRange -> AgeRange -> Bool
(AgeRange -> AgeRange -> Bool)
-> (AgeRange -> AgeRange -> Bool) -> Eq AgeRange
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]
(Int -> ReadS AgeRange)
-> ReadS [AgeRange]
-> ReadPrec AgeRange
-> ReadPrec [AgeRange]
-> Read 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
(Int -> AgeRange -> ShowS)
-> (AgeRange -> String) -> ([AgeRange] -> ShowS) -> Show AgeRange
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. AgeRange -> Rep AgeRange x)
-> (forall x. Rep AgeRange x -> AgeRange) -> Generic AgeRange
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:
--
-- 'low', 'ageRange_low' - The lowest estimated age.
--
-- 'high', 'ageRange_high' - The highest estimated age.
newAgeRange ::
  AgeRange
newAgeRange :: AgeRange
newAgeRange =
  AgeRange' :: Maybe Natural -> Maybe Natural -> AgeRange
AgeRange'
    { $sel:low:AgeRange' :: Maybe Natural
low = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:high:AgeRange' :: Maybe Natural
high = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The lowest estimated age.
ageRange_low :: Lens.Lens' AgeRange (Prelude.Maybe Prelude.Natural)
ageRange_low :: (Maybe Natural -> f (Maybe Natural)) -> AgeRange -> f AgeRange
ageRange_low = (AgeRange -> Maybe Natural)
-> (AgeRange -> Maybe Natural -> AgeRange)
-> Lens AgeRange AgeRange (Maybe Natural) (Maybe Natural)
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)

-- | The highest estimated age.
ageRange_high :: Lens.Lens' AgeRange (Prelude.Maybe Prelude.Natural)
ageRange_high :: (Maybe Natural -> f (Maybe Natural)) -> AgeRange -> f AgeRange
ageRange_high = (AgeRange -> Maybe Natural)
-> (AgeRange -> Maybe Natural -> AgeRange)
-> Lens AgeRange AgeRange (Maybe Natural) (Maybe Natural)
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)

instance Core.FromJSON AgeRange where
  parseJSON :: Value -> Parser AgeRange
parseJSON =
    String -> (Object -> Parser AgeRange) -> Value -> Parser AgeRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AgeRange"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> AgeRange
AgeRange'
            (Maybe Natural -> Maybe Natural -> AgeRange)
-> Parser (Maybe Natural) -> Parser (Maybe Natural -> AgeRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Low") Parser (Maybe Natural -> AgeRange)
-> Parser (Maybe Natural) -> Parser AgeRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"High")
      )

instance Prelude.Hashable AgeRange

instance Prelude.NFData AgeRange