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

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

-- | Returns information about a set of differences for a commit specifier.
--
-- /See:/ 'newDifference' smart constructor.
data Difference = Difference'
  { -- | Information about an @afterBlob@ data type object, including the ID, the
    -- file mode permission code, and the path.
    Difference -> Maybe BlobMetadata
afterBlob :: Prelude.Maybe BlobMetadata,
    -- | Information about a @beforeBlob@ data type object, including the ID, the
    -- file mode permission code, and the path.
    Difference -> Maybe BlobMetadata
beforeBlob :: Prelude.Maybe BlobMetadata,
    -- | Whether the change type of the difference is an addition (A), deletion
    -- (D), or modification (M).
    Difference -> Maybe ChangeTypeEnum
changeType :: Prelude.Maybe ChangeTypeEnum
  }
  deriving (Difference -> Difference -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Difference -> Difference -> Bool
$c/= :: Difference -> Difference -> Bool
== :: Difference -> Difference -> Bool
$c== :: Difference -> Difference -> Bool
Prelude.Eq, ReadPrec [Difference]
ReadPrec Difference
Int -> ReadS Difference
ReadS [Difference]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Difference]
$creadListPrec :: ReadPrec [Difference]
readPrec :: ReadPrec Difference
$creadPrec :: ReadPrec Difference
readList :: ReadS [Difference]
$creadList :: ReadS [Difference]
readsPrec :: Int -> ReadS Difference
$creadsPrec :: Int -> ReadS Difference
Prelude.Read, Int -> Difference -> ShowS
[Difference] -> ShowS
Difference -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Difference] -> ShowS
$cshowList :: [Difference] -> ShowS
show :: Difference -> String
$cshow :: Difference -> String
showsPrec :: Int -> Difference -> ShowS
$cshowsPrec :: Int -> Difference -> ShowS
Prelude.Show, forall x. Rep Difference x -> Difference
forall x. Difference -> Rep Difference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Difference x -> Difference
$cfrom :: forall x. Difference -> Rep Difference x
Prelude.Generic)

-- |
-- Create a value of 'Difference' 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:
--
-- 'afterBlob', 'difference_afterBlob' - Information about an @afterBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
--
-- 'beforeBlob', 'difference_beforeBlob' - Information about a @beforeBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
--
-- 'changeType', 'difference_changeType' - Whether the change type of the difference is an addition (A), deletion
-- (D), or modification (M).
newDifference ::
  Difference
newDifference :: Difference
newDifference =
  Difference'
    { $sel:afterBlob:Difference' :: Maybe BlobMetadata
afterBlob = forall a. Maybe a
Prelude.Nothing,
      $sel:beforeBlob:Difference' :: Maybe BlobMetadata
beforeBlob = forall a. Maybe a
Prelude.Nothing,
      $sel:changeType:Difference' :: Maybe ChangeTypeEnum
changeType = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about an @afterBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
difference_afterBlob :: Lens.Lens' Difference (Prelude.Maybe BlobMetadata)
difference_afterBlob :: Lens' Difference (Maybe BlobMetadata)
difference_afterBlob = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Difference' {Maybe BlobMetadata
afterBlob :: Maybe BlobMetadata
$sel:afterBlob:Difference' :: Difference -> Maybe BlobMetadata
afterBlob} -> Maybe BlobMetadata
afterBlob) (\s :: Difference
s@Difference' {} Maybe BlobMetadata
a -> Difference
s {$sel:afterBlob:Difference' :: Maybe BlobMetadata
afterBlob = Maybe BlobMetadata
a} :: Difference)

-- | Information about a @beforeBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
difference_beforeBlob :: Lens.Lens' Difference (Prelude.Maybe BlobMetadata)
difference_beforeBlob :: Lens' Difference (Maybe BlobMetadata)
difference_beforeBlob = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Difference' {Maybe BlobMetadata
beforeBlob :: Maybe BlobMetadata
$sel:beforeBlob:Difference' :: Difference -> Maybe BlobMetadata
beforeBlob} -> Maybe BlobMetadata
beforeBlob) (\s :: Difference
s@Difference' {} Maybe BlobMetadata
a -> Difference
s {$sel:beforeBlob:Difference' :: Maybe BlobMetadata
beforeBlob = Maybe BlobMetadata
a} :: Difference)

-- | Whether the change type of the difference is an addition (A), deletion
-- (D), or modification (M).
difference_changeType :: Lens.Lens' Difference (Prelude.Maybe ChangeTypeEnum)
difference_changeType :: Lens' Difference (Maybe ChangeTypeEnum)
difference_changeType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Difference' {Maybe ChangeTypeEnum
changeType :: Maybe ChangeTypeEnum
$sel:changeType:Difference' :: Difference -> Maybe ChangeTypeEnum
changeType} -> Maybe ChangeTypeEnum
changeType) (\s :: Difference
s@Difference' {} Maybe ChangeTypeEnum
a -> Difference
s {$sel:changeType:Difference' :: Maybe ChangeTypeEnum
changeType = Maybe ChangeTypeEnum
a} :: Difference)

instance Data.FromJSON Difference where
  parseJSON :: Value -> Parser Difference
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Difference"
      ( \Object
x ->
          Maybe BlobMetadata
-> Maybe BlobMetadata -> Maybe ChangeTypeEnum -> Difference
Difference'
            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
"afterBlob")
            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
"beforeBlob")
            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
"changeType")
      )

instance Prelude.Hashable Difference where
  hashWithSalt :: Int -> Difference -> Int
hashWithSalt Int
_salt Difference' {Maybe BlobMetadata
Maybe ChangeTypeEnum
changeType :: Maybe ChangeTypeEnum
beforeBlob :: Maybe BlobMetadata
afterBlob :: Maybe BlobMetadata
$sel:changeType:Difference' :: Difference -> Maybe ChangeTypeEnum
$sel:beforeBlob:Difference' :: Difference -> Maybe BlobMetadata
$sel:afterBlob:Difference' :: Difference -> Maybe BlobMetadata
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BlobMetadata
afterBlob
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BlobMetadata
beforeBlob
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChangeTypeEnum
changeType

instance Prelude.NFData Difference where
  rnf :: Difference -> ()
rnf Difference' {Maybe BlobMetadata
Maybe ChangeTypeEnum
changeType :: Maybe ChangeTypeEnum
beforeBlob :: Maybe BlobMetadata
afterBlob :: Maybe BlobMetadata
$sel:changeType:Difference' :: Difference -> Maybe ChangeTypeEnum
$sel:beforeBlob:Difference' :: Difference -> Maybe BlobMetadata
$sel:afterBlob:Difference' :: Difference -> Maybe BlobMetadata
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BlobMetadata
afterBlob
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BlobMetadata
beforeBlob
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ChangeTypeEnum
changeType