{-# 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.MigrationHubStrategy.Types.Group
-- 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.MigrationHubStrategy.Types.Group where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MigrationHubStrategy.Types.GroupName
import qualified Amazonka.Prelude as Prelude

-- | The object containing information about distinct imports or groups for
-- Strategy Recommendations.
--
-- /See:/ 'newGroup' smart constructor.
data Group = Group'
  { -- | The key of the specific import group.
    Group -> Maybe GroupName
name :: Prelude.Maybe GroupName,
    -- | The value of the specific import group.
    Group -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (Group -> Group -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Group -> Group -> Bool
$c/= :: Group -> Group -> Bool
== :: Group -> Group -> Bool
$c== :: Group -> Group -> Bool
Prelude.Eq, ReadPrec [Group]
ReadPrec Group
Int -> ReadS Group
ReadS [Group]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Group]
$creadListPrec :: ReadPrec [Group]
readPrec :: ReadPrec Group
$creadPrec :: ReadPrec Group
readList :: ReadS [Group]
$creadList :: ReadS [Group]
readsPrec :: Int -> ReadS Group
$creadsPrec :: Int -> ReadS Group
Prelude.Read, Int -> Group -> ShowS
[Group] -> ShowS
Group -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Group] -> ShowS
$cshowList :: [Group] -> ShowS
show :: Group -> String
$cshow :: Group -> String
showsPrec :: Int -> Group -> ShowS
$cshowsPrec :: Int -> Group -> ShowS
Prelude.Show, forall x. Rep Group x -> Group
forall x. Group -> Rep Group x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Group x -> Group
$cfrom :: forall x. Group -> Rep Group x
Prelude.Generic)

-- |
-- Create a value of 'Group' 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:
--
-- 'name', 'group_name' - The key of the specific import group.
--
-- 'value', 'group_value' - The value of the specific import group.
newGroup ::
  Group
newGroup :: Group
newGroup =
  Group'
    { $sel:name:Group' :: Maybe GroupName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Group' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The key of the specific import group.
group_name :: Lens.Lens' Group (Prelude.Maybe GroupName)
group_name :: Lens' Group (Maybe GroupName)
group_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Group' {Maybe GroupName
name :: Maybe GroupName
$sel:name:Group' :: Group -> Maybe GroupName
name} -> Maybe GroupName
name) (\s :: Group
s@Group' {} Maybe GroupName
a -> Group
s {$sel:name:Group' :: Maybe GroupName
name = Maybe GroupName
a} :: Group)

-- | The value of the specific import group.
group_value :: Lens.Lens' Group (Prelude.Maybe Prelude.Text)
group_value :: Lens' Group (Maybe Text)
group_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Group' {Maybe Text
value :: Maybe Text
$sel:value:Group' :: Group -> Maybe Text
value} -> Maybe Text
value) (\s :: Group
s@Group' {} Maybe Text
a -> Group
s {$sel:value:Group' :: Maybe Text
value = Maybe Text
a} :: Group)

instance Prelude.Hashable Group where
  hashWithSalt :: Int -> Group -> Int
hashWithSalt Int
_salt Group' {Maybe Text
Maybe GroupName
value :: Maybe Text
name :: Maybe GroupName
$sel:value:Group' :: Group -> Maybe Text
$sel:name:Group' :: Group -> Maybe GroupName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GroupName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData Group where
  rnf :: Group -> ()
rnf Group' {Maybe Text
Maybe GroupName
value :: Maybe Text
name :: Maybe GroupName
$sel:value:Group' :: Group -> Maybe Text
$sel:name:Group' :: Group -> Maybe GroupName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe GroupName
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

instance Data.ToJSON Group where
  toJSON :: Group -> Value
toJSON Group' {Maybe Text
Maybe GroupName
value :: Maybe Text
name :: Maybe GroupName
$sel:value:Group' :: Group -> Maybe Text
$sel:name:Group' :: Group -> Maybe GroupName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GroupName
name,
            (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
value
          ]
      )