{-# 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.Consolidation
-- 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.Consolidation 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 matching criteria to be used during the auto-merging process.
--
-- /See:/ 'newConsolidation' smart constructor.
data Consolidation = Consolidation'
  { -- | A list of matching criteria.
    Consolidation -> NonEmpty (NonEmpty Text)
matchingAttributesList :: Prelude.NonEmpty (Prelude.NonEmpty Prelude.Text)
  }
  deriving (Consolidation -> Consolidation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Consolidation -> Consolidation -> Bool
$c/= :: Consolidation -> Consolidation -> Bool
== :: Consolidation -> Consolidation -> Bool
$c== :: Consolidation -> Consolidation -> Bool
Prelude.Eq, ReadPrec [Consolidation]
ReadPrec Consolidation
Int -> ReadS Consolidation
ReadS [Consolidation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Consolidation]
$creadListPrec :: ReadPrec [Consolidation]
readPrec :: ReadPrec Consolidation
$creadPrec :: ReadPrec Consolidation
readList :: ReadS [Consolidation]
$creadList :: ReadS [Consolidation]
readsPrec :: Int -> ReadS Consolidation
$creadsPrec :: Int -> ReadS Consolidation
Prelude.Read, Int -> Consolidation -> ShowS
[Consolidation] -> ShowS
Consolidation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Consolidation] -> ShowS
$cshowList :: [Consolidation] -> ShowS
show :: Consolidation -> String
$cshow :: Consolidation -> String
showsPrec :: Int -> Consolidation -> ShowS
$cshowsPrec :: Int -> Consolidation -> ShowS
Prelude.Show, forall x. Rep Consolidation x -> Consolidation
forall x. Consolidation -> Rep Consolidation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Consolidation x -> Consolidation
$cfrom :: forall x. Consolidation -> Rep Consolidation x
Prelude.Generic)

-- |
-- Create a value of 'Consolidation' 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:
--
-- 'matchingAttributesList', 'consolidation_matchingAttributesList' - A list of matching criteria.
newConsolidation ::
  -- | 'matchingAttributesList'
  Prelude.NonEmpty (Prelude.NonEmpty Prelude.Text) ->
  Consolidation
newConsolidation :: NonEmpty (NonEmpty Text) -> Consolidation
newConsolidation NonEmpty (NonEmpty Text)
pMatchingAttributesList_ =
  Consolidation'
    { $sel:matchingAttributesList:Consolidation' :: NonEmpty (NonEmpty Text)
matchingAttributesList =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty (NonEmpty Text)
pMatchingAttributesList_
    }

-- | A list of matching criteria.
consolidation_matchingAttributesList :: Lens.Lens' Consolidation (Prelude.NonEmpty (Prelude.NonEmpty Prelude.Text))
consolidation_matchingAttributesList :: Lens' Consolidation (NonEmpty (NonEmpty Text))
consolidation_matchingAttributesList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Consolidation' {NonEmpty (NonEmpty Text)
matchingAttributesList :: NonEmpty (NonEmpty Text)
$sel:matchingAttributesList:Consolidation' :: Consolidation -> NonEmpty (NonEmpty Text)
matchingAttributesList} -> NonEmpty (NonEmpty Text)
matchingAttributesList) (\s :: Consolidation
s@Consolidation' {} NonEmpty (NonEmpty Text)
a -> Consolidation
s {$sel:matchingAttributesList:Consolidation' :: NonEmpty (NonEmpty Text)
matchingAttributesList = NonEmpty (NonEmpty Text)
a} :: Consolidation) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON Consolidation where
  parseJSON :: Value -> Parser Consolidation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Consolidation"
      ( \Object
x ->
          NonEmpty (NonEmpty Text) -> Consolidation
Consolidation'
            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
"MatchingAttributesList")
      )

instance Prelude.Hashable Consolidation where
  hashWithSalt :: Int -> Consolidation -> Int
hashWithSalt Int
_salt Consolidation' {NonEmpty (NonEmpty Text)
matchingAttributesList :: NonEmpty (NonEmpty Text)
$sel:matchingAttributesList:Consolidation' :: Consolidation -> NonEmpty (NonEmpty Text)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty (NonEmpty Text)
matchingAttributesList

instance Prelude.NFData Consolidation where
  rnf :: Consolidation -> ()
rnf Consolidation' {NonEmpty (NonEmpty Text)
matchingAttributesList :: NonEmpty (NonEmpty Text)
$sel:matchingAttributesList:Consolidation' :: Consolidation -> NonEmpty (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty (NonEmpty Text)
matchingAttributesList

instance Data.ToJSON Consolidation where
  toJSON :: Consolidation -> Value
toJSON Consolidation' {NonEmpty (NonEmpty Text)
matchingAttributesList :: NonEmpty (NonEmpty Text)
$sel:matchingAttributesList:Consolidation' :: Consolidation -> NonEmpty (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"MatchingAttributesList"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty (NonEmpty Text)
matchingAttributesList
              )
          ]
      )