{-# 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.LexV2Models.Types.SlotTypeSortBy
-- 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.LexV2Models.Types.SlotTypeSortBy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.SlotTypeSortAttribute
import Amazonka.LexV2Models.Types.SortOrder
import qualified Amazonka.Prelude as Prelude

-- | Specifies attributes for sorting a list of slot types.
--
-- /See:/ 'newSlotTypeSortBy' smart constructor.
data SlotTypeSortBy = SlotTypeSortBy'
  { -- | The attribute to use to sort the list of slot types.
    SlotTypeSortBy -> SlotTypeSortAttribute
attribute :: SlotTypeSortAttribute,
    -- | The order to sort the list. You can say ascending or descending.
    SlotTypeSortBy -> SortOrder
order :: SortOrder
  }
  deriving (SlotTypeSortBy -> SlotTypeSortBy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotTypeSortBy -> SlotTypeSortBy -> Bool
$c/= :: SlotTypeSortBy -> SlotTypeSortBy -> Bool
== :: SlotTypeSortBy -> SlotTypeSortBy -> Bool
$c== :: SlotTypeSortBy -> SlotTypeSortBy -> Bool
Prelude.Eq, ReadPrec [SlotTypeSortBy]
ReadPrec SlotTypeSortBy
Int -> ReadS SlotTypeSortBy
ReadS [SlotTypeSortBy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotTypeSortBy]
$creadListPrec :: ReadPrec [SlotTypeSortBy]
readPrec :: ReadPrec SlotTypeSortBy
$creadPrec :: ReadPrec SlotTypeSortBy
readList :: ReadS [SlotTypeSortBy]
$creadList :: ReadS [SlotTypeSortBy]
readsPrec :: Int -> ReadS SlotTypeSortBy
$creadsPrec :: Int -> ReadS SlotTypeSortBy
Prelude.Read, Int -> SlotTypeSortBy -> ShowS
[SlotTypeSortBy] -> ShowS
SlotTypeSortBy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotTypeSortBy] -> ShowS
$cshowList :: [SlotTypeSortBy] -> ShowS
show :: SlotTypeSortBy -> String
$cshow :: SlotTypeSortBy -> String
showsPrec :: Int -> SlotTypeSortBy -> ShowS
$cshowsPrec :: Int -> SlotTypeSortBy -> ShowS
Prelude.Show, forall x. Rep SlotTypeSortBy x -> SlotTypeSortBy
forall x. SlotTypeSortBy -> Rep SlotTypeSortBy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotTypeSortBy x -> SlotTypeSortBy
$cfrom :: forall x. SlotTypeSortBy -> Rep SlotTypeSortBy x
Prelude.Generic)

-- |
-- Create a value of 'SlotTypeSortBy' 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:
--
-- 'attribute', 'slotTypeSortBy_attribute' - The attribute to use to sort the list of slot types.
--
-- 'order', 'slotTypeSortBy_order' - The order to sort the list. You can say ascending or descending.
newSlotTypeSortBy ::
  -- | 'attribute'
  SlotTypeSortAttribute ->
  -- | 'order'
  SortOrder ->
  SlotTypeSortBy
newSlotTypeSortBy :: SlotTypeSortAttribute -> SortOrder -> SlotTypeSortBy
newSlotTypeSortBy SlotTypeSortAttribute
pAttribute_ SortOrder
pOrder_ =
  SlotTypeSortBy'
    { $sel:attribute:SlotTypeSortBy' :: SlotTypeSortAttribute
attribute = SlotTypeSortAttribute
pAttribute_,
      $sel:order:SlotTypeSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The attribute to use to sort the list of slot types.
slotTypeSortBy_attribute :: Lens.Lens' SlotTypeSortBy SlotTypeSortAttribute
slotTypeSortBy_attribute :: Lens' SlotTypeSortBy SlotTypeSortAttribute
slotTypeSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeSortBy' {SlotTypeSortAttribute
attribute :: SlotTypeSortAttribute
$sel:attribute:SlotTypeSortBy' :: SlotTypeSortBy -> SlotTypeSortAttribute
attribute} -> SlotTypeSortAttribute
attribute) (\s :: SlotTypeSortBy
s@SlotTypeSortBy' {} SlotTypeSortAttribute
a -> SlotTypeSortBy
s {$sel:attribute:SlotTypeSortBy' :: SlotTypeSortAttribute
attribute = SlotTypeSortAttribute
a} :: SlotTypeSortBy)

-- | The order to sort the list. You can say ascending or descending.
slotTypeSortBy_order :: Lens.Lens' SlotTypeSortBy SortOrder
slotTypeSortBy_order :: Lens' SlotTypeSortBy SortOrder
slotTypeSortBy_order = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeSortBy' {SortOrder
order :: SortOrder
$sel:order:SlotTypeSortBy' :: SlotTypeSortBy -> SortOrder
order} -> SortOrder
order) (\s :: SlotTypeSortBy
s@SlotTypeSortBy' {} SortOrder
a -> SlotTypeSortBy
s {$sel:order:SlotTypeSortBy' :: SortOrder
order = SortOrder
a} :: SlotTypeSortBy)

instance Prelude.Hashable SlotTypeSortBy where
  hashWithSalt :: Int -> SlotTypeSortBy -> Int
hashWithSalt Int
_salt SlotTypeSortBy' {SlotTypeSortAttribute
SortOrder
order :: SortOrder
attribute :: SlotTypeSortAttribute
$sel:order:SlotTypeSortBy' :: SlotTypeSortBy -> SortOrder
$sel:attribute:SlotTypeSortBy' :: SlotTypeSortBy -> SlotTypeSortAttribute
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SlotTypeSortAttribute
attribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SortOrder
order

instance Prelude.NFData SlotTypeSortBy where
  rnf :: SlotTypeSortBy -> ()
rnf SlotTypeSortBy' {SlotTypeSortAttribute
SortOrder
order :: SortOrder
attribute :: SlotTypeSortAttribute
$sel:order:SlotTypeSortBy' :: SlotTypeSortBy -> SortOrder
$sel:attribute:SlotTypeSortBy' :: SlotTypeSortBy -> SlotTypeSortAttribute
..} =
    forall a. NFData a => a -> ()
Prelude.rnf SlotTypeSortAttribute
attribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SortOrder
order

instance Data.ToJSON SlotTypeSortBy where
  toJSON :: SlotTypeSortBy -> Value
toJSON SlotTypeSortBy' {SlotTypeSortAttribute
SortOrder
order :: SortOrder
attribute :: SlotTypeSortAttribute
$sel:order:SlotTypeSortBy' :: SlotTypeSortBy -> SortOrder
$sel:attribute:SlotTypeSortBy' :: SlotTypeSortBy -> SlotTypeSortAttribute
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"attribute" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SlotTypeSortAttribute
attribute),
            forall a. a -> Maybe a
Prelude.Just (Key
"order" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SortOrder
order)
          ]
      )