{-# 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.IAM.Types.Position
-- 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.IAM.Types.Position 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

-- | Contains the row and column of a location of a @Statement@ element in a
-- policy document.
--
-- This data type is used as a member of the @ @@Statement@@ @ type.
--
-- /See:/ 'newPosition' smart constructor.
data Position = Position'
  { -- | The column in the line containing the specified position in the
    -- document.
    Position -> Maybe Int
column :: Prelude.Maybe Prelude.Int,
    -- | The line containing the specified position in the document.
    Position -> Maybe Int
line :: Prelude.Maybe Prelude.Int
  }
  deriving (Position -> Position -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Position -> Position -> Bool
$c/= :: Position -> Position -> Bool
== :: Position -> Position -> Bool
$c== :: Position -> Position -> Bool
Prelude.Eq, ReadPrec [Position]
ReadPrec Position
Int -> ReadS Position
ReadS [Position]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Position]
$creadListPrec :: ReadPrec [Position]
readPrec :: ReadPrec Position
$creadPrec :: ReadPrec Position
readList :: ReadS [Position]
$creadList :: ReadS [Position]
readsPrec :: Int -> ReadS Position
$creadsPrec :: Int -> ReadS Position
Prelude.Read, Int -> Position -> ShowS
[Position] -> ShowS
Position -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Position] -> ShowS
$cshowList :: [Position] -> ShowS
show :: Position -> String
$cshow :: Position -> String
showsPrec :: Int -> Position -> ShowS
$cshowsPrec :: Int -> Position -> ShowS
Prelude.Show, forall x. Rep Position x -> Position
forall x. Position -> Rep Position x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Position x -> Position
$cfrom :: forall x. Position -> Rep Position x
Prelude.Generic)

-- |
-- Create a value of 'Position' 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:
--
-- 'column', 'position_column' - The column in the line containing the specified position in the
-- document.
--
-- 'line', 'position_line' - The line containing the specified position in the document.
newPosition ::
  Position
newPosition :: Position
newPosition =
  Position'
    { $sel:column:Position' :: Maybe Int
column = forall a. Maybe a
Prelude.Nothing,
      $sel:line:Position' :: Maybe Int
line = forall a. Maybe a
Prelude.Nothing
    }

-- | The column in the line containing the specified position in the
-- document.
position_column :: Lens.Lens' Position (Prelude.Maybe Prelude.Int)
position_column :: Lens' Position (Maybe Int)
position_column = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Position' {Maybe Int
column :: Maybe Int
$sel:column:Position' :: Position -> Maybe Int
column} -> Maybe Int
column) (\s :: Position
s@Position' {} Maybe Int
a -> Position
s {$sel:column:Position' :: Maybe Int
column = Maybe Int
a} :: Position)

-- | The line containing the specified position in the document.
position_line :: Lens.Lens' Position (Prelude.Maybe Prelude.Int)
position_line :: Lens' Position (Maybe Int)
position_line = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Position' {Maybe Int
line :: Maybe Int
$sel:line:Position' :: Position -> Maybe Int
line} -> Maybe Int
line) (\s :: Position
s@Position' {} Maybe Int
a -> Position
s {$sel:line:Position' :: Maybe Int
line = Maybe Int
a} :: Position)

instance Data.FromXML Position where
  parseXML :: [Node] -> Either String Position
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> Position
Position'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Column")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Line")

instance Prelude.Hashable Position where
  hashWithSalt :: Int -> Position -> Int
hashWithSalt Int
_salt Position' {Maybe Int
line :: Maybe Int
column :: Maybe Int
$sel:line:Position' :: Position -> Maybe Int
$sel:column:Position' :: Position -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
column
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
line

instance Prelude.NFData Position where
  rnf :: Position -> ()
rnf Position' {Maybe Int
line :: Maybe Int
column :: Maybe Int
$sel:line:Position' :: Position -> Maybe Int
$sel:column:Position' :: Position -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
column seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
line