{-# 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 #-}
module Amazonka.M2.Types.PrimaryKey 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
data PrimaryKey = PrimaryKey'
{
PrimaryKey -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
PrimaryKey -> Int
length :: Prelude.Int,
PrimaryKey -> Int
offset :: Prelude.Int
}
deriving (PrimaryKey -> PrimaryKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrimaryKey -> PrimaryKey -> Bool
$c/= :: PrimaryKey -> PrimaryKey -> Bool
== :: PrimaryKey -> PrimaryKey -> Bool
$c== :: PrimaryKey -> PrimaryKey -> Bool
Prelude.Eq, ReadPrec [PrimaryKey]
ReadPrec PrimaryKey
Int -> ReadS PrimaryKey
ReadS [PrimaryKey]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrimaryKey]
$creadListPrec :: ReadPrec [PrimaryKey]
readPrec :: ReadPrec PrimaryKey
$creadPrec :: ReadPrec PrimaryKey
readList :: ReadS [PrimaryKey]
$creadList :: ReadS [PrimaryKey]
readsPrec :: Int -> ReadS PrimaryKey
$creadsPrec :: Int -> ReadS PrimaryKey
Prelude.Read, Int -> PrimaryKey -> ShowS
[PrimaryKey] -> ShowS
PrimaryKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrimaryKey] -> ShowS
$cshowList :: [PrimaryKey] -> ShowS
show :: PrimaryKey -> String
$cshow :: PrimaryKey -> String
showsPrec :: Int -> PrimaryKey -> ShowS
$cshowsPrec :: Int -> PrimaryKey -> ShowS
Prelude.Show, forall x. Rep PrimaryKey x -> PrimaryKey
forall x. PrimaryKey -> Rep PrimaryKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PrimaryKey x -> PrimaryKey
$cfrom :: forall x. PrimaryKey -> Rep PrimaryKey x
Prelude.Generic)
newPrimaryKey ::
Prelude.Int ->
Prelude.Int ->
PrimaryKey
newPrimaryKey :: Int -> Int -> PrimaryKey
newPrimaryKey Int
pLength_ Int
pOffset_ =
PrimaryKey'
{ $sel:name:PrimaryKey' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
$sel:length:PrimaryKey' :: Int
length = Int
pLength_,
$sel:offset:PrimaryKey' :: Int
offset = Int
pOffset_
}
primaryKey_name :: Lens.Lens' PrimaryKey (Prelude.Maybe Prelude.Text)
primaryKey_name :: Lens' PrimaryKey (Maybe Text)
primaryKey_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrimaryKey' {Maybe Text
name :: Maybe Text
$sel:name:PrimaryKey' :: PrimaryKey -> Maybe Text
name} -> Maybe Text
name) (\s :: PrimaryKey
s@PrimaryKey' {} Maybe Text
a -> PrimaryKey
s {$sel:name:PrimaryKey' :: Maybe Text
name = Maybe Text
a} :: PrimaryKey)
primaryKey_length :: Lens.Lens' PrimaryKey Prelude.Int
primaryKey_length :: Lens' PrimaryKey Int
primaryKey_length = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrimaryKey' {Int
length :: Int
$sel:length:PrimaryKey' :: PrimaryKey -> Int
length} -> Int
length) (\s :: PrimaryKey
s@PrimaryKey' {} Int
a -> PrimaryKey
s {$sel:length:PrimaryKey' :: Int
length = Int
a} :: PrimaryKey)
primaryKey_offset :: Lens.Lens' PrimaryKey Prelude.Int
primaryKey_offset :: Lens' PrimaryKey Int
primaryKey_offset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrimaryKey' {Int
offset :: Int
$sel:offset:PrimaryKey' :: PrimaryKey -> Int
offset} -> Int
offset) (\s :: PrimaryKey
s@PrimaryKey' {} Int
a -> PrimaryKey
s {$sel:offset:PrimaryKey' :: Int
offset = Int
a} :: PrimaryKey)
instance Data.FromJSON PrimaryKey where
parseJSON :: Value -> Parser PrimaryKey
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"PrimaryKey"
( \Object
x ->
Maybe Text -> Int -> Int -> PrimaryKey
PrimaryKey'
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
"name")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"length")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"offset")
)
instance Prelude.Hashable PrimaryKey where
hashWithSalt :: Int -> PrimaryKey -> Int
hashWithSalt Int
_salt PrimaryKey' {Int
Maybe Text
offset :: Int
length :: Int
name :: Maybe Text
$sel:offset:PrimaryKey' :: PrimaryKey -> Int
$sel:length:PrimaryKey' :: PrimaryKey -> Int
$sel:name:PrimaryKey' :: PrimaryKey -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
length
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
offset
instance Prelude.NFData PrimaryKey where
rnf :: PrimaryKey -> ()
rnf PrimaryKey' {Int
Maybe Text
offset :: Int
length :: Int
name :: Maybe Text
$sel:offset:PrimaryKey' :: PrimaryKey -> Int
$sel:length:PrimaryKey' :: PrimaryKey -> Int
$sel:name:PrimaryKey' :: PrimaryKey -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
length
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
offset
instance Data.ToJSON PrimaryKey where
toJSON :: PrimaryKey -> Value
toJSON PrimaryKey' {Int
Maybe Text
offset :: Int
length :: Int
name :: Maybe Text
$sel:offset:PrimaryKey' :: PrimaryKey -> Int
$sel:length:PrimaryKey' :: PrimaryKey -> Int
$sel:name:PrimaryKey' :: PrimaryKey -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
forall a. a -> Maybe a
Prelude.Just (Key
"length" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
length),
forall a. a -> Maybe a
Prelude.Just (Key
"offset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
offset)
]
)