{-# 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.M2.Types.RecordLength
-- 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.M2.Types.RecordLength 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

-- | The length of the records in the data set.
--
-- /See:/ 'newRecordLength' smart constructor.
data RecordLength = RecordLength'
  { -- | The maximum record length. In case of fixed, both minimum and maximum
    -- are the same.
    RecordLength -> Int
max :: Prelude.Int,
    -- | The minimum record length of a record.
    RecordLength -> Int
min :: Prelude.Int
  }
  deriving (RecordLength -> RecordLength -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecordLength -> RecordLength -> Bool
$c/= :: RecordLength -> RecordLength -> Bool
== :: RecordLength -> RecordLength -> Bool
$c== :: RecordLength -> RecordLength -> Bool
Prelude.Eq, ReadPrec [RecordLength]
ReadPrec RecordLength
Int -> ReadS RecordLength
ReadS [RecordLength]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecordLength]
$creadListPrec :: ReadPrec [RecordLength]
readPrec :: ReadPrec RecordLength
$creadPrec :: ReadPrec RecordLength
readList :: ReadS [RecordLength]
$creadList :: ReadS [RecordLength]
readsPrec :: Int -> ReadS RecordLength
$creadsPrec :: Int -> ReadS RecordLength
Prelude.Read, Int -> RecordLength -> ShowS
[RecordLength] -> ShowS
RecordLength -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecordLength] -> ShowS
$cshowList :: [RecordLength] -> ShowS
show :: RecordLength -> String
$cshow :: RecordLength -> String
showsPrec :: Int -> RecordLength -> ShowS
$cshowsPrec :: Int -> RecordLength -> ShowS
Prelude.Show, forall x. Rep RecordLength x -> RecordLength
forall x. RecordLength -> Rep RecordLength x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecordLength x -> RecordLength
$cfrom :: forall x. RecordLength -> Rep RecordLength x
Prelude.Generic)

-- |
-- Create a value of 'RecordLength' 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:
--
-- 'max', 'recordLength_max' - The maximum record length. In case of fixed, both minimum and maximum
-- are the same.
--
-- 'min', 'recordLength_min' - The minimum record length of a record.
newRecordLength ::
  -- | 'max'
  Prelude.Int ->
  -- | 'min'
  Prelude.Int ->
  RecordLength
newRecordLength :: Int -> Int -> RecordLength
newRecordLength Int
pMax_ Int
pMin_ =
  RecordLength' {$sel:max:RecordLength' :: Int
max = Int
pMax_, $sel:min:RecordLength' :: Int
min = Int
pMin_}

-- | The maximum record length. In case of fixed, both minimum and maximum
-- are the same.
recordLength_max :: Lens.Lens' RecordLength Prelude.Int
recordLength_max :: Lens' RecordLength Int
recordLength_max = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordLength' {Int
max :: Int
$sel:max:RecordLength' :: RecordLength -> Int
max} -> Int
max) (\s :: RecordLength
s@RecordLength' {} Int
a -> RecordLength
s {$sel:max:RecordLength' :: Int
max = Int
a} :: RecordLength)

-- | The minimum record length of a record.
recordLength_min :: Lens.Lens' RecordLength Prelude.Int
recordLength_min :: Lens' RecordLength Int
recordLength_min = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecordLength' {Int
min :: Int
$sel:min:RecordLength' :: RecordLength -> Int
min} -> Int
min) (\s :: RecordLength
s@RecordLength' {} Int
a -> RecordLength
s {$sel:min:RecordLength' :: Int
min = Int
a} :: RecordLength)

instance Prelude.Hashable RecordLength where
  hashWithSalt :: Int -> RecordLength -> Int
hashWithSalt Int
_salt RecordLength' {Int
min :: Int
max :: Int
$sel:min:RecordLength' :: RecordLength -> Int
$sel:max:RecordLength' :: RecordLength -> Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
max
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
min

instance Prelude.NFData RecordLength where
  rnf :: RecordLength -> ()
rnf RecordLength' {Int
min :: Int
max :: Int
$sel:min:RecordLength' :: RecordLength -> Int
$sel:max:RecordLength' :: RecordLength -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
max seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
min

instance Data.ToJSON RecordLength where
  toJSON :: RecordLength -> Value
toJSON RecordLength' {Int
min :: Int
max :: Int
$sel:min:RecordLength' :: RecordLength -> Int
$sel:max:RecordLength' :: RecordLength -> Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"max" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
max),
            forall a. a -> Maybe a
Prelude.Just (Key
"min" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
min)
          ]
      )