{-# 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.MergeHunkDetail
-- 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.MergeHunkDetail where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the details of a merge hunk that contains a conflict
-- in a merge or pull request operation.
--
-- /See:/ 'newMergeHunkDetail' smart constructor.
data MergeHunkDetail = MergeHunkDetail'
  { -- | The start position of the hunk in the merge result.
    MergeHunkDetail -> Maybe Int
startLine :: Prelude.Maybe Prelude.Int,
    -- | The end position of the hunk in the merge result.
    MergeHunkDetail -> Maybe Int
endLine :: Prelude.Maybe Prelude.Int,
    -- | The base-64 encoded content of the hunk merged region that might contain
    -- a conflict.
    MergeHunkDetail -> Maybe Text
hunkContent :: Prelude.Maybe Prelude.Text
  }
  deriving (MergeHunkDetail -> MergeHunkDetail -> Bool
(MergeHunkDetail -> MergeHunkDetail -> Bool)
-> (MergeHunkDetail -> MergeHunkDetail -> Bool)
-> Eq MergeHunkDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MergeHunkDetail -> MergeHunkDetail -> Bool
$c/= :: MergeHunkDetail -> MergeHunkDetail -> Bool
== :: MergeHunkDetail -> MergeHunkDetail -> Bool
$c== :: MergeHunkDetail -> MergeHunkDetail -> Bool
Prelude.Eq, ReadPrec [MergeHunkDetail]
ReadPrec MergeHunkDetail
Int -> ReadS MergeHunkDetail
ReadS [MergeHunkDetail]
(Int -> ReadS MergeHunkDetail)
-> ReadS [MergeHunkDetail]
-> ReadPrec MergeHunkDetail
-> ReadPrec [MergeHunkDetail]
-> Read MergeHunkDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MergeHunkDetail]
$creadListPrec :: ReadPrec [MergeHunkDetail]
readPrec :: ReadPrec MergeHunkDetail
$creadPrec :: ReadPrec MergeHunkDetail
readList :: ReadS [MergeHunkDetail]
$creadList :: ReadS [MergeHunkDetail]
readsPrec :: Int -> ReadS MergeHunkDetail
$creadsPrec :: Int -> ReadS MergeHunkDetail
Prelude.Read, Int -> MergeHunkDetail -> ShowS
[MergeHunkDetail] -> ShowS
MergeHunkDetail -> String
(Int -> MergeHunkDetail -> ShowS)
-> (MergeHunkDetail -> String)
-> ([MergeHunkDetail] -> ShowS)
-> Show MergeHunkDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MergeHunkDetail] -> ShowS
$cshowList :: [MergeHunkDetail] -> ShowS
show :: MergeHunkDetail -> String
$cshow :: MergeHunkDetail -> String
showsPrec :: Int -> MergeHunkDetail -> ShowS
$cshowsPrec :: Int -> MergeHunkDetail -> ShowS
Prelude.Show, (forall x. MergeHunkDetail -> Rep MergeHunkDetail x)
-> (forall x. Rep MergeHunkDetail x -> MergeHunkDetail)
-> Generic MergeHunkDetail
forall x. Rep MergeHunkDetail x -> MergeHunkDetail
forall x. MergeHunkDetail -> Rep MergeHunkDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MergeHunkDetail x -> MergeHunkDetail
$cfrom :: forall x. MergeHunkDetail -> Rep MergeHunkDetail x
Prelude.Generic)

-- |
-- Create a value of 'MergeHunkDetail' 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:
--
-- 'startLine', 'mergeHunkDetail_startLine' - The start position of the hunk in the merge result.
--
-- 'endLine', 'mergeHunkDetail_endLine' - The end position of the hunk in the merge result.
--
-- 'hunkContent', 'mergeHunkDetail_hunkContent' - The base-64 encoded content of the hunk merged region that might contain
-- a conflict.
newMergeHunkDetail ::
  MergeHunkDetail
newMergeHunkDetail :: MergeHunkDetail
newMergeHunkDetail =
  MergeHunkDetail' :: Maybe Int -> Maybe Int -> Maybe Text -> MergeHunkDetail
MergeHunkDetail'
    { $sel:startLine:MergeHunkDetail' :: Maybe Int
startLine = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:endLine:MergeHunkDetail' :: Maybe Int
endLine = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:hunkContent:MergeHunkDetail' :: Maybe Text
hunkContent = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The start position of the hunk in the merge result.
mergeHunkDetail_startLine :: Lens.Lens' MergeHunkDetail (Prelude.Maybe Prelude.Int)
mergeHunkDetail_startLine :: (Maybe Int -> f (Maybe Int))
-> MergeHunkDetail -> f MergeHunkDetail
mergeHunkDetail_startLine = (MergeHunkDetail -> Maybe Int)
-> (MergeHunkDetail -> Maybe Int -> MergeHunkDetail)
-> Lens MergeHunkDetail MergeHunkDetail (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeHunkDetail' {Maybe Int
startLine :: Maybe Int
$sel:startLine:MergeHunkDetail' :: MergeHunkDetail -> Maybe Int
startLine} -> Maybe Int
startLine) (\s :: MergeHunkDetail
s@MergeHunkDetail' {} Maybe Int
a -> MergeHunkDetail
s {$sel:startLine:MergeHunkDetail' :: Maybe Int
startLine = Maybe Int
a} :: MergeHunkDetail)

-- | The end position of the hunk in the merge result.
mergeHunkDetail_endLine :: Lens.Lens' MergeHunkDetail (Prelude.Maybe Prelude.Int)
mergeHunkDetail_endLine :: (Maybe Int -> f (Maybe Int))
-> MergeHunkDetail -> f MergeHunkDetail
mergeHunkDetail_endLine = (MergeHunkDetail -> Maybe Int)
-> (MergeHunkDetail -> Maybe Int -> MergeHunkDetail)
-> Lens MergeHunkDetail MergeHunkDetail (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeHunkDetail' {Maybe Int
endLine :: Maybe Int
$sel:endLine:MergeHunkDetail' :: MergeHunkDetail -> Maybe Int
endLine} -> Maybe Int
endLine) (\s :: MergeHunkDetail
s@MergeHunkDetail' {} Maybe Int
a -> MergeHunkDetail
s {$sel:endLine:MergeHunkDetail' :: Maybe Int
endLine = Maybe Int
a} :: MergeHunkDetail)

-- | The base-64 encoded content of the hunk merged region that might contain
-- a conflict.
mergeHunkDetail_hunkContent :: Lens.Lens' MergeHunkDetail (Prelude.Maybe Prelude.Text)
mergeHunkDetail_hunkContent :: (Maybe Text -> f (Maybe Text))
-> MergeHunkDetail -> f MergeHunkDetail
mergeHunkDetail_hunkContent = (MergeHunkDetail -> Maybe Text)
-> (MergeHunkDetail -> Maybe Text -> MergeHunkDetail)
-> Lens MergeHunkDetail MergeHunkDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeHunkDetail' {Maybe Text
hunkContent :: Maybe Text
$sel:hunkContent:MergeHunkDetail' :: MergeHunkDetail -> Maybe Text
hunkContent} -> Maybe Text
hunkContent) (\s :: MergeHunkDetail
s@MergeHunkDetail' {} Maybe Text
a -> MergeHunkDetail
s {$sel:hunkContent:MergeHunkDetail' :: Maybe Text
hunkContent = Maybe Text
a} :: MergeHunkDetail)

instance Core.FromJSON MergeHunkDetail where
  parseJSON :: Value -> Parser MergeHunkDetail
parseJSON =
    String
-> (Object -> Parser MergeHunkDetail)
-> Value
-> Parser MergeHunkDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MergeHunkDetail"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Maybe Text -> MergeHunkDetail
MergeHunkDetail'
            (Maybe Int -> Maybe Int -> Maybe Text -> MergeHunkDetail)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> Maybe Text -> MergeHunkDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"startLine")
            Parser (Maybe Int -> Maybe Text -> MergeHunkDetail)
-> Parser (Maybe Int) -> Parser (Maybe Text -> MergeHunkDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"endLine")
            Parser (Maybe Text -> MergeHunkDetail)
-> Parser (Maybe Text) -> Parser MergeHunkDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hunkContent")
      )

instance Prelude.Hashable MergeHunkDetail

instance Prelude.NFData MergeHunkDetail