{-# 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.CustomerProfiles.Types.MatchItem
-- 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.CustomerProfiles.Types.MatchItem 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

-- | The Match group object.
--
-- /See:/ 'newMatchItem' smart constructor.
data MatchItem = MatchItem'
  { -- | A number between 0 and 1, where a higher score means higher similarity.
    -- Examining match confidence scores lets you distinguish between groups of
    -- similar records in which the system is highly confident (which you may
    -- decide to merge), groups of similar records about which the system is
    -- uncertain (which you may decide to have reviewed by a human), and groups
    -- of similar records that the system deems to be unlikely (which you may
    -- decide to reject). Given confidence scores vary as per the data input,
    -- it should not be used an absolute measure of matching quality.
    MatchItem -> Maybe Double
confidenceScore :: Prelude.Maybe Prelude.Double,
    -- | The unique identifiers for this group of profiles that match.
    MatchItem -> Maybe Text
matchId :: Prelude.Maybe Prelude.Text,
    -- | A list of identifiers for profiles that match.
    MatchItem -> Maybe [Text]
profileIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (MatchItem -> MatchItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MatchItem -> MatchItem -> Bool
$c/= :: MatchItem -> MatchItem -> Bool
== :: MatchItem -> MatchItem -> Bool
$c== :: MatchItem -> MatchItem -> Bool
Prelude.Eq, ReadPrec [MatchItem]
ReadPrec MatchItem
Int -> ReadS MatchItem
ReadS [MatchItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MatchItem]
$creadListPrec :: ReadPrec [MatchItem]
readPrec :: ReadPrec MatchItem
$creadPrec :: ReadPrec MatchItem
readList :: ReadS [MatchItem]
$creadList :: ReadS [MatchItem]
readsPrec :: Int -> ReadS MatchItem
$creadsPrec :: Int -> ReadS MatchItem
Prelude.Read, Int -> MatchItem -> ShowS
[MatchItem] -> ShowS
MatchItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MatchItem] -> ShowS
$cshowList :: [MatchItem] -> ShowS
show :: MatchItem -> String
$cshow :: MatchItem -> String
showsPrec :: Int -> MatchItem -> ShowS
$cshowsPrec :: Int -> MatchItem -> ShowS
Prelude.Show, forall x. Rep MatchItem x -> MatchItem
forall x. MatchItem -> Rep MatchItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MatchItem x -> MatchItem
$cfrom :: forall x. MatchItem -> Rep MatchItem x
Prelude.Generic)

-- |
-- Create a value of 'MatchItem' 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:
--
-- 'confidenceScore', 'matchItem_confidenceScore' - A number between 0 and 1, where a higher score means higher similarity.
-- Examining match confidence scores lets you distinguish between groups of
-- similar records in which the system is highly confident (which you may
-- decide to merge), groups of similar records about which the system is
-- uncertain (which you may decide to have reviewed by a human), and groups
-- of similar records that the system deems to be unlikely (which you may
-- decide to reject). Given confidence scores vary as per the data input,
-- it should not be used an absolute measure of matching quality.
--
-- 'matchId', 'matchItem_matchId' - The unique identifiers for this group of profiles that match.
--
-- 'profileIds', 'matchItem_profileIds' - A list of identifiers for profiles that match.
newMatchItem ::
  MatchItem
newMatchItem :: MatchItem
newMatchItem =
  MatchItem'
    { $sel:confidenceScore:MatchItem' :: Maybe Double
confidenceScore = forall a. Maybe a
Prelude.Nothing,
      $sel:matchId:MatchItem' :: Maybe Text
matchId = forall a. Maybe a
Prelude.Nothing,
      $sel:profileIds:MatchItem' :: Maybe [Text]
profileIds = forall a. Maybe a
Prelude.Nothing
    }

-- | A number between 0 and 1, where a higher score means higher similarity.
-- Examining match confidence scores lets you distinguish between groups of
-- similar records in which the system is highly confident (which you may
-- decide to merge), groups of similar records about which the system is
-- uncertain (which you may decide to have reviewed by a human), and groups
-- of similar records that the system deems to be unlikely (which you may
-- decide to reject). Given confidence scores vary as per the data input,
-- it should not be used an absolute measure of matching quality.
matchItem_confidenceScore :: Lens.Lens' MatchItem (Prelude.Maybe Prelude.Double)
matchItem_confidenceScore :: Lens' MatchItem (Maybe Double)
matchItem_confidenceScore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchItem' {Maybe Double
confidenceScore :: Maybe Double
$sel:confidenceScore:MatchItem' :: MatchItem -> Maybe Double
confidenceScore} -> Maybe Double
confidenceScore) (\s :: MatchItem
s@MatchItem' {} Maybe Double
a -> MatchItem
s {$sel:confidenceScore:MatchItem' :: Maybe Double
confidenceScore = Maybe Double
a} :: MatchItem)

-- | The unique identifiers for this group of profiles that match.
matchItem_matchId :: Lens.Lens' MatchItem (Prelude.Maybe Prelude.Text)
matchItem_matchId :: Lens' MatchItem (Maybe Text)
matchItem_matchId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchItem' {Maybe Text
matchId :: Maybe Text
$sel:matchId:MatchItem' :: MatchItem -> Maybe Text
matchId} -> Maybe Text
matchId) (\s :: MatchItem
s@MatchItem' {} Maybe Text
a -> MatchItem
s {$sel:matchId:MatchItem' :: Maybe Text
matchId = Maybe Text
a} :: MatchItem)

-- | A list of identifiers for profiles that match.
matchItem_profileIds :: Lens.Lens' MatchItem (Prelude.Maybe [Prelude.Text])
matchItem_profileIds :: Lens' MatchItem (Maybe [Text])
matchItem_profileIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchItem' {Maybe [Text]
profileIds :: Maybe [Text]
$sel:profileIds:MatchItem' :: MatchItem -> Maybe [Text]
profileIds} -> Maybe [Text]
profileIds) (\s :: MatchItem
s@MatchItem' {} Maybe [Text]
a -> MatchItem
s {$sel:profileIds:MatchItem' :: Maybe [Text]
profileIds = Maybe [Text]
a} :: MatchItem) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON MatchItem where
  parseJSON :: Value -> Parser MatchItem
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MatchItem"
      ( \Object
x ->
          Maybe Double -> Maybe Text -> Maybe [Text] -> MatchItem
MatchItem'
            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
"ConfidenceScore")
            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
"MatchId")
            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
"ProfileIds" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable MatchItem where
  hashWithSalt :: Int -> MatchItem -> Int
hashWithSalt Int
_salt MatchItem' {Maybe Double
Maybe [Text]
Maybe Text
profileIds :: Maybe [Text]
matchId :: Maybe Text
confidenceScore :: Maybe Double
$sel:profileIds:MatchItem' :: MatchItem -> Maybe [Text]
$sel:matchId:MatchItem' :: MatchItem -> Maybe Text
$sel:confidenceScore:MatchItem' :: MatchItem -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
confidenceScore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
matchId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
profileIds

instance Prelude.NFData MatchItem where
  rnf :: MatchItem -> ()
rnf MatchItem' {Maybe Double
Maybe [Text]
Maybe Text
profileIds :: Maybe [Text]
matchId :: Maybe Text
confidenceScore :: Maybe Double
$sel:profileIds:MatchItem' :: MatchItem -> Maybe [Text]
$sel:matchId:MatchItem' :: MatchItem -> Maybe Text
$sel:confidenceScore:MatchItem' :: MatchItem -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
confidenceScore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
matchId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
profileIds