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

-- | 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 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,
    -- | The start position of the hunk in the merge result.
    MergeHunkDetail -> Maybe Int
startLine :: Prelude.Maybe Prelude.Int
  }
  deriving (MergeHunkDetail -> MergeHunkDetail -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'startLine', 'mergeHunkDetail_startLine' - The start position of the hunk in the merge result.
newMergeHunkDetail ::
  MergeHunkDetail
newMergeHunkDetail :: MergeHunkDetail
newMergeHunkDetail =
  MergeHunkDetail'
    { $sel:endLine:MergeHunkDetail' :: Maybe Int
endLine = forall a. Maybe a
Prelude.Nothing,
      $sel:hunkContent:MergeHunkDetail' :: Maybe Text
hunkContent = forall a. Maybe a
Prelude.Nothing,
      $sel:startLine:MergeHunkDetail' :: Maybe Int
startLine = forall a. Maybe a
Prelude.Nothing
    }

-- | The end position of the hunk in the merge result.
mergeHunkDetail_endLine :: Lens.Lens' MergeHunkDetail (Prelude.Maybe Prelude.Int)
mergeHunkDetail_endLine :: Lens' MergeHunkDetail (Maybe Int)
mergeHunkDetail_endLine = 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 :: Lens' MergeHunkDetail (Maybe Text)
mergeHunkDetail_hunkContent = 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)

-- | The start position of the hunk in the merge result.
mergeHunkDetail_startLine :: Lens.Lens' MergeHunkDetail (Prelude.Maybe Prelude.Int)
mergeHunkDetail_startLine :: Lens' MergeHunkDetail (Maybe Int)
mergeHunkDetail_startLine = 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)

instance Data.FromJSON MergeHunkDetail where
  parseJSON :: Value -> Parser MergeHunkDetail
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MergeHunkDetail"
      ( \Object
x ->
          Maybe Int -> Maybe Text -> Maybe Int -> MergeHunkDetail
MergeHunkDetail'
            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
"endLine")
            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
"hunkContent")
            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
"startLine")
      )

instance Prelude.Hashable MergeHunkDetail where
  hashWithSalt :: Int -> MergeHunkDetail -> Int
hashWithSalt Int
_salt MergeHunkDetail' {Maybe Int
Maybe Text
startLine :: Maybe Int
hunkContent :: Maybe Text
endLine :: Maybe Int
$sel:startLine:MergeHunkDetail' :: MergeHunkDetail -> Maybe Int
$sel:hunkContent:MergeHunkDetail' :: MergeHunkDetail -> Maybe Text
$sel:endLine:MergeHunkDetail' :: MergeHunkDetail -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
endLine
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hunkContent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
startLine

instance Prelude.NFData MergeHunkDetail where
  rnf :: MergeHunkDetail -> ()
rnf MergeHunkDetail' {Maybe Int
Maybe Text
startLine :: Maybe Int
hunkContent :: Maybe Text
endLine :: Maybe Int
$sel:startLine:MergeHunkDetail' :: MergeHunkDetail -> Maybe Int
$sel:hunkContent:MergeHunkDetail' :: MergeHunkDetail -> Maybe Text
$sel:endLine:MergeHunkDetail' :: MergeHunkDetail -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
endLine
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hunkContent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
startLine