{-# 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.CodeCommit.Types.MergeOperations
-- 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.CodeCommit.Types.MergeOperations where

import Amazonka.CodeCommit.Types.ChangeTypeEnum
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

-- | Information about the file operation conflicts in a merge operation.
--
-- /See:/ 'newMergeOperations' smart constructor.
data MergeOperations = MergeOperations'
  { -- | The operation on a file in the destination of a merge or pull request.
    MergeOperations -> Maybe ChangeTypeEnum
destination :: Prelude.Maybe ChangeTypeEnum,
    -- | The operation (add, modify, or delete) on a file in the source of a
    -- merge or pull request.
    MergeOperations -> Maybe ChangeTypeEnum
source :: Prelude.Maybe ChangeTypeEnum
  }
  deriving (MergeOperations -> MergeOperations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MergeOperations -> MergeOperations -> Bool
$c/= :: MergeOperations -> MergeOperations -> Bool
== :: MergeOperations -> MergeOperations -> Bool
$c== :: MergeOperations -> MergeOperations -> Bool
Prelude.Eq, ReadPrec [MergeOperations]
ReadPrec MergeOperations
Int -> ReadS MergeOperations
ReadS [MergeOperations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MergeOperations]
$creadListPrec :: ReadPrec [MergeOperations]
readPrec :: ReadPrec MergeOperations
$creadPrec :: ReadPrec MergeOperations
readList :: ReadS [MergeOperations]
$creadList :: ReadS [MergeOperations]
readsPrec :: Int -> ReadS MergeOperations
$creadsPrec :: Int -> ReadS MergeOperations
Prelude.Read, Int -> MergeOperations -> ShowS
[MergeOperations] -> ShowS
MergeOperations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MergeOperations] -> ShowS
$cshowList :: [MergeOperations] -> ShowS
show :: MergeOperations -> String
$cshow :: MergeOperations -> String
showsPrec :: Int -> MergeOperations -> ShowS
$cshowsPrec :: Int -> MergeOperations -> ShowS
Prelude.Show, forall x. Rep MergeOperations x -> MergeOperations
forall x. MergeOperations -> Rep MergeOperations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MergeOperations x -> MergeOperations
$cfrom :: forall x. MergeOperations -> Rep MergeOperations x
Prelude.Generic)

-- |
-- Create a value of 'MergeOperations' 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:
--
-- 'destination', 'mergeOperations_destination' - The operation on a file in the destination of a merge or pull request.
--
-- 'source', 'mergeOperations_source' - The operation (add, modify, or delete) on a file in the source of a
-- merge or pull request.
newMergeOperations ::
  MergeOperations
newMergeOperations :: MergeOperations
newMergeOperations =
  MergeOperations'
    { $sel:destination:MergeOperations' :: Maybe ChangeTypeEnum
destination = forall a. Maybe a
Prelude.Nothing,
      $sel:source:MergeOperations' :: Maybe ChangeTypeEnum
source = forall a. Maybe a
Prelude.Nothing
    }

-- | The operation on a file in the destination of a merge or pull request.
mergeOperations_destination :: Lens.Lens' MergeOperations (Prelude.Maybe ChangeTypeEnum)
mergeOperations_destination :: Lens' MergeOperations (Maybe ChangeTypeEnum)
mergeOperations_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeOperations' {Maybe ChangeTypeEnum
destination :: Maybe ChangeTypeEnum
$sel:destination:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
destination} -> Maybe ChangeTypeEnum
destination) (\s :: MergeOperations
s@MergeOperations' {} Maybe ChangeTypeEnum
a -> MergeOperations
s {$sel:destination:MergeOperations' :: Maybe ChangeTypeEnum
destination = Maybe ChangeTypeEnum
a} :: MergeOperations)

-- | The operation (add, modify, or delete) on a file in the source of a
-- merge or pull request.
mergeOperations_source :: Lens.Lens' MergeOperations (Prelude.Maybe ChangeTypeEnum)
mergeOperations_source :: Lens' MergeOperations (Maybe ChangeTypeEnum)
mergeOperations_source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeOperations' {Maybe ChangeTypeEnum
source :: Maybe ChangeTypeEnum
$sel:source:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
source} -> Maybe ChangeTypeEnum
source) (\s :: MergeOperations
s@MergeOperations' {} Maybe ChangeTypeEnum
a -> MergeOperations
s {$sel:source:MergeOperations' :: Maybe ChangeTypeEnum
source = Maybe ChangeTypeEnum
a} :: MergeOperations)

instance Data.FromJSON MergeOperations where
  parseJSON :: Value -> Parser MergeOperations
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MergeOperations"
      ( \Object
x ->
          Maybe ChangeTypeEnum -> Maybe ChangeTypeEnum -> MergeOperations
MergeOperations'
            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
"destination")
            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
"source")
      )

instance Prelude.Hashable MergeOperations where
  hashWithSalt :: Int -> MergeOperations -> Int
hashWithSalt Int
_salt MergeOperations' {Maybe ChangeTypeEnum
source :: Maybe ChangeTypeEnum
destination :: Maybe ChangeTypeEnum
$sel:source:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
$sel:destination:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChangeTypeEnum
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChangeTypeEnum
source

instance Prelude.NFData MergeOperations where
  rnf :: MergeOperations -> ()
rnf MergeOperations' {Maybe ChangeTypeEnum
source :: Maybe ChangeTypeEnum
destination :: Maybe ChangeTypeEnum
$sel:source:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
$sel:destination:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ChangeTypeEnum
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ChangeTypeEnum
source