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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.GenderType

-- | The predicted gender of a detected face.
--
-- Amazon Rekognition makes gender binary (male\/female) predictions based
-- on the physical appearance of a face in a particular image. This kind of
-- prediction is not designed to categorize a person’s gender identity, and
-- you shouldn\'t use Amazon Rekognition to make such a determination. For
-- example, a male actor wearing a long-haired wig and earrings for a role
-- might be predicted as female.
--
-- Using Amazon Rekognition to make gender binary predictions is best
-- suited for use cases where aggregate gender distribution statistics need
-- to be analyzed without identifying specific users. For example, the
-- percentage of female users compared to male users on a social media
-- platform.
--
-- We don\'t recommend using gender binary predictions to make decisions
-- that impact
 an individual\'s rights, privacy, or access to services.
--
-- /See:/ 'newGender' smart constructor.
data Gender = Gender'
  { -- | The predicted gender of the face.
    Gender -> Maybe GenderType
value :: Prelude.Maybe GenderType,
    -- | Level of confidence in the prediction.
    Gender -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double
  }
  deriving (Gender -> Gender -> Bool
(Gender -> Gender -> Bool)
-> (Gender -> Gender -> Bool) -> Eq Gender
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Gender -> Gender -> Bool
$c/= :: Gender -> Gender -> Bool
== :: Gender -> Gender -> Bool
$c== :: Gender -> Gender -> Bool
Prelude.Eq, ReadPrec [Gender]
ReadPrec Gender
Int -> ReadS Gender
ReadS [Gender]
(Int -> ReadS Gender)
-> ReadS [Gender]
-> ReadPrec Gender
-> ReadPrec [Gender]
-> Read Gender
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Gender]
$creadListPrec :: ReadPrec [Gender]
readPrec :: ReadPrec Gender
$creadPrec :: ReadPrec Gender
readList :: ReadS [Gender]
$creadList :: ReadS [Gender]
readsPrec :: Int -> ReadS Gender
$creadsPrec :: Int -> ReadS Gender
Prelude.Read, Int -> Gender -> ShowS
[Gender] -> ShowS
Gender -> String
(Int -> Gender -> ShowS)
-> (Gender -> String) -> ([Gender] -> ShowS) -> Show Gender
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Gender] -> ShowS
$cshowList :: [Gender] -> ShowS
show :: Gender -> String
$cshow :: Gender -> String
showsPrec :: Int -> Gender -> ShowS
$cshowsPrec :: Int -> Gender -> ShowS
Prelude.Show, (forall x. Gender -> Rep Gender x)
-> (forall x. Rep Gender x -> Gender) -> Generic Gender
forall x. Rep Gender x -> Gender
forall x. Gender -> Rep Gender x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Gender x -> Gender
$cfrom :: forall x. Gender -> Rep Gender x
Prelude.Generic)

-- |
-- Create a value of 'Gender' 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:
--
-- 'value', 'gender_value' - The predicted gender of the face.
--
-- 'confidence', 'gender_confidence' - Level of confidence in the prediction.
newGender ::
  Gender
newGender :: Gender
newGender =
  Gender' :: Maybe GenderType -> Maybe Double -> Gender
Gender'
    { $sel:value:Gender' :: Maybe GenderType
value = Maybe GenderType
forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:Gender' :: Maybe Double
confidence = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The predicted gender of the face.
gender_value :: Lens.Lens' Gender (Prelude.Maybe GenderType)
gender_value :: (Maybe GenderType -> f (Maybe GenderType)) -> Gender -> f Gender
gender_value = (Gender -> Maybe GenderType)
-> (Gender -> Maybe GenderType -> Gender)
-> Lens Gender Gender (Maybe GenderType) (Maybe GenderType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Gender' {Maybe GenderType
value :: Maybe GenderType
$sel:value:Gender' :: Gender -> Maybe GenderType
value} -> Maybe GenderType
value) (\s :: Gender
s@Gender' {} Maybe GenderType
a -> Gender
s {$sel:value:Gender' :: Maybe GenderType
value = Maybe GenderType
a} :: Gender)

-- | Level of confidence in the prediction.
gender_confidence :: Lens.Lens' Gender (Prelude.Maybe Prelude.Double)
gender_confidence :: (Maybe Double -> f (Maybe Double)) -> Gender -> f Gender
gender_confidence = (Gender -> Maybe Double)
-> (Gender -> Maybe Double -> Gender)
-> Lens Gender Gender (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Gender' {Maybe Double
confidence :: Maybe Double
$sel:confidence:Gender' :: Gender -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: Gender
s@Gender' {} Maybe Double
a -> Gender
s {$sel:confidence:Gender' :: Maybe Double
confidence = Maybe Double
a} :: Gender)

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

instance Prelude.Hashable Gender

instance Prelude.NFData Gender