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

import Amazonka.CodeCommit.Types.MergeHunkDetail
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about merge hunks in a merge or pull request operation.
--
-- /See:/ 'newMergeHunk' smart constructor.
data MergeHunk = MergeHunk'
  { -- | Information about the merge hunk in the destination of a merge or pull
    -- request.
    MergeHunk -> Maybe MergeHunkDetail
destination :: Prelude.Maybe MergeHunkDetail,
    -- | Information about the merge hunk in the base of a merge or pull request.
    MergeHunk -> Maybe MergeHunkDetail
base :: Prelude.Maybe MergeHunkDetail,
    -- | A Boolean value indicating whether a combination of hunks contains a
    -- conflict. Conflicts occur when the same file or the same lines in a file
    -- were modified in both the source and destination of a merge or pull
    -- request. Valid values include true, false, and null. True when the hunk
    -- represents a conflict and one or more files contains a line conflict.
    -- File mode conflicts in a merge do not set this to true.
    MergeHunk -> Maybe Bool
isConflict :: Prelude.Maybe Prelude.Bool,
    -- | Information about the merge hunk in the source of a merge or pull
    -- request.
    MergeHunk -> Maybe MergeHunkDetail
source :: Prelude.Maybe MergeHunkDetail
  }
  deriving (MergeHunk -> MergeHunk -> Bool
(MergeHunk -> MergeHunk -> Bool)
-> (MergeHunk -> MergeHunk -> Bool) -> Eq MergeHunk
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MergeHunk -> MergeHunk -> Bool
$c/= :: MergeHunk -> MergeHunk -> Bool
== :: MergeHunk -> MergeHunk -> Bool
$c== :: MergeHunk -> MergeHunk -> Bool
Prelude.Eq, ReadPrec [MergeHunk]
ReadPrec MergeHunk
Int -> ReadS MergeHunk
ReadS [MergeHunk]
(Int -> ReadS MergeHunk)
-> ReadS [MergeHunk]
-> ReadPrec MergeHunk
-> ReadPrec [MergeHunk]
-> Read MergeHunk
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MergeHunk]
$creadListPrec :: ReadPrec [MergeHunk]
readPrec :: ReadPrec MergeHunk
$creadPrec :: ReadPrec MergeHunk
readList :: ReadS [MergeHunk]
$creadList :: ReadS [MergeHunk]
readsPrec :: Int -> ReadS MergeHunk
$creadsPrec :: Int -> ReadS MergeHunk
Prelude.Read, Int -> MergeHunk -> ShowS
[MergeHunk] -> ShowS
MergeHunk -> String
(Int -> MergeHunk -> ShowS)
-> (MergeHunk -> String)
-> ([MergeHunk] -> ShowS)
-> Show MergeHunk
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MergeHunk] -> ShowS
$cshowList :: [MergeHunk] -> ShowS
show :: MergeHunk -> String
$cshow :: MergeHunk -> String
showsPrec :: Int -> MergeHunk -> ShowS
$cshowsPrec :: Int -> MergeHunk -> ShowS
Prelude.Show, (forall x. MergeHunk -> Rep MergeHunk x)
-> (forall x. Rep MergeHunk x -> MergeHunk) -> Generic MergeHunk
forall x. Rep MergeHunk x -> MergeHunk
forall x. MergeHunk -> Rep MergeHunk x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MergeHunk x -> MergeHunk
$cfrom :: forall x. MergeHunk -> Rep MergeHunk x
Prelude.Generic)

-- |
-- Create a value of 'MergeHunk' 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', 'mergeHunk_destination' - Information about the merge hunk in the destination of a merge or pull
-- request.
--
-- 'base', 'mergeHunk_base' - Information about the merge hunk in the base of a merge or pull request.
--
-- 'isConflict', 'mergeHunk_isConflict' - A Boolean value indicating whether a combination of hunks contains a
-- conflict. Conflicts occur when the same file or the same lines in a file
-- were modified in both the source and destination of a merge or pull
-- request. Valid values include true, false, and null. True when the hunk
-- represents a conflict and one or more files contains a line conflict.
-- File mode conflicts in a merge do not set this to true.
--
-- 'source', 'mergeHunk_source' - Information about the merge hunk in the source of a merge or pull
-- request.
newMergeHunk ::
  MergeHunk
newMergeHunk :: MergeHunk
newMergeHunk =
  MergeHunk' :: Maybe MergeHunkDetail
-> Maybe MergeHunkDetail
-> Maybe Bool
-> Maybe MergeHunkDetail
-> MergeHunk
MergeHunk'
    { $sel:destination:MergeHunk' :: Maybe MergeHunkDetail
destination = Maybe MergeHunkDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:base:MergeHunk' :: Maybe MergeHunkDetail
base = Maybe MergeHunkDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:isConflict:MergeHunk' :: Maybe Bool
isConflict = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:source:MergeHunk' :: Maybe MergeHunkDetail
source = Maybe MergeHunkDetail
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the merge hunk in the destination of a merge or pull
-- request.
mergeHunk_destination :: Lens.Lens' MergeHunk (Prelude.Maybe MergeHunkDetail)
mergeHunk_destination :: (Maybe MergeHunkDetail -> f (Maybe MergeHunkDetail))
-> MergeHunk -> f MergeHunk
mergeHunk_destination = (MergeHunk -> Maybe MergeHunkDetail)
-> (MergeHunk -> Maybe MergeHunkDetail -> MergeHunk)
-> Lens
     MergeHunk MergeHunk (Maybe MergeHunkDetail) (Maybe MergeHunkDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeHunk' {Maybe MergeHunkDetail
destination :: Maybe MergeHunkDetail
$sel:destination:MergeHunk' :: MergeHunk -> Maybe MergeHunkDetail
destination} -> Maybe MergeHunkDetail
destination) (\s :: MergeHunk
s@MergeHunk' {} Maybe MergeHunkDetail
a -> MergeHunk
s {$sel:destination:MergeHunk' :: Maybe MergeHunkDetail
destination = Maybe MergeHunkDetail
a} :: MergeHunk)

-- | Information about the merge hunk in the base of a merge or pull request.
mergeHunk_base :: Lens.Lens' MergeHunk (Prelude.Maybe MergeHunkDetail)
mergeHunk_base :: (Maybe MergeHunkDetail -> f (Maybe MergeHunkDetail))
-> MergeHunk -> f MergeHunk
mergeHunk_base = (MergeHunk -> Maybe MergeHunkDetail)
-> (MergeHunk -> Maybe MergeHunkDetail -> MergeHunk)
-> Lens
     MergeHunk MergeHunk (Maybe MergeHunkDetail) (Maybe MergeHunkDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeHunk' {Maybe MergeHunkDetail
base :: Maybe MergeHunkDetail
$sel:base:MergeHunk' :: MergeHunk -> Maybe MergeHunkDetail
base} -> Maybe MergeHunkDetail
base) (\s :: MergeHunk
s@MergeHunk' {} Maybe MergeHunkDetail
a -> MergeHunk
s {$sel:base:MergeHunk' :: Maybe MergeHunkDetail
base = Maybe MergeHunkDetail
a} :: MergeHunk)

-- | A Boolean value indicating whether a combination of hunks contains a
-- conflict. Conflicts occur when the same file or the same lines in a file
-- were modified in both the source and destination of a merge or pull
-- request. Valid values include true, false, and null. True when the hunk
-- represents a conflict and one or more files contains a line conflict.
-- File mode conflicts in a merge do not set this to true.
mergeHunk_isConflict :: Lens.Lens' MergeHunk (Prelude.Maybe Prelude.Bool)
mergeHunk_isConflict :: (Maybe Bool -> f (Maybe Bool)) -> MergeHunk -> f MergeHunk
mergeHunk_isConflict = (MergeHunk -> Maybe Bool)
-> (MergeHunk -> Maybe Bool -> MergeHunk)
-> Lens MergeHunk MergeHunk (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeHunk' {Maybe Bool
isConflict :: Maybe Bool
$sel:isConflict:MergeHunk' :: MergeHunk -> Maybe Bool
isConflict} -> Maybe Bool
isConflict) (\s :: MergeHunk
s@MergeHunk' {} Maybe Bool
a -> MergeHunk
s {$sel:isConflict:MergeHunk' :: Maybe Bool
isConflict = Maybe Bool
a} :: MergeHunk)

-- | Information about the merge hunk in the source of a merge or pull
-- request.
mergeHunk_source :: Lens.Lens' MergeHunk (Prelude.Maybe MergeHunkDetail)
mergeHunk_source :: (Maybe MergeHunkDetail -> f (Maybe MergeHunkDetail))
-> MergeHunk -> f MergeHunk
mergeHunk_source = (MergeHunk -> Maybe MergeHunkDetail)
-> (MergeHunk -> Maybe MergeHunkDetail -> MergeHunk)
-> Lens
     MergeHunk MergeHunk (Maybe MergeHunkDetail) (Maybe MergeHunkDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeHunk' {Maybe MergeHunkDetail
source :: Maybe MergeHunkDetail
$sel:source:MergeHunk' :: MergeHunk -> Maybe MergeHunkDetail
source} -> Maybe MergeHunkDetail
source) (\s :: MergeHunk
s@MergeHunk' {} Maybe MergeHunkDetail
a -> MergeHunk
s {$sel:source:MergeHunk' :: Maybe MergeHunkDetail
source = Maybe MergeHunkDetail
a} :: MergeHunk)

instance Core.FromJSON MergeHunk where
  parseJSON :: Value -> Parser MergeHunk
parseJSON =
    String -> (Object -> Parser MergeHunk) -> Value -> Parser MergeHunk
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MergeHunk"
      ( \Object
x ->
          Maybe MergeHunkDetail
-> Maybe MergeHunkDetail
-> Maybe Bool
-> Maybe MergeHunkDetail
-> MergeHunk
MergeHunk'
            (Maybe MergeHunkDetail
 -> Maybe MergeHunkDetail
 -> Maybe Bool
 -> Maybe MergeHunkDetail
 -> MergeHunk)
-> Parser (Maybe MergeHunkDetail)
-> Parser
     (Maybe MergeHunkDetail
      -> Maybe Bool -> Maybe MergeHunkDetail -> MergeHunk)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MergeHunkDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"destination")
            Parser
  (Maybe MergeHunkDetail
   -> Maybe Bool -> Maybe MergeHunkDetail -> MergeHunk)
-> Parser (Maybe MergeHunkDetail)
-> Parser (Maybe Bool -> Maybe MergeHunkDetail -> MergeHunk)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MergeHunkDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"base")
            Parser (Maybe Bool -> Maybe MergeHunkDetail -> MergeHunk)
-> Parser (Maybe Bool)
-> Parser (Maybe MergeHunkDetail -> MergeHunk)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isConflict")
            Parser (Maybe MergeHunkDetail -> MergeHunk)
-> Parser (Maybe MergeHunkDetail) -> Parser MergeHunk
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MergeHunkDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"source")
      )

instance Prelude.Hashable MergeHunk

instance Prelude.NFData MergeHunk