{-# 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.ImportSortBy
-- 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.ImportSortBy 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.ImportSortAttribute
import Amazonka.LexV2Models.Types.SortOrder
import qualified Amazonka.Prelude as Prelude

-- | Provides information for sorting a list of imports.
--
-- /See:/ 'newImportSortBy' smart constructor.
data ImportSortBy = ImportSortBy'
  { -- | The export field to use for sorting.
    ImportSortBy -> ImportSortAttribute
attribute :: ImportSortAttribute,
    -- | The order to sort the list.
    ImportSortBy -> SortOrder
order :: SortOrder
  }
  deriving (ImportSortBy -> ImportSortBy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportSortBy -> ImportSortBy -> Bool
$c/= :: ImportSortBy -> ImportSortBy -> Bool
== :: ImportSortBy -> ImportSortBy -> Bool
$c== :: ImportSortBy -> ImportSortBy -> Bool
Prelude.Eq, ReadPrec [ImportSortBy]
ReadPrec ImportSortBy
Int -> ReadS ImportSortBy
ReadS [ImportSortBy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportSortBy]
$creadListPrec :: ReadPrec [ImportSortBy]
readPrec :: ReadPrec ImportSortBy
$creadPrec :: ReadPrec ImportSortBy
readList :: ReadS [ImportSortBy]
$creadList :: ReadS [ImportSortBy]
readsPrec :: Int -> ReadS ImportSortBy
$creadsPrec :: Int -> ReadS ImportSortBy
Prelude.Read, Int -> ImportSortBy -> ShowS
[ImportSortBy] -> ShowS
ImportSortBy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportSortBy] -> ShowS
$cshowList :: [ImportSortBy] -> ShowS
show :: ImportSortBy -> String
$cshow :: ImportSortBy -> String
showsPrec :: Int -> ImportSortBy -> ShowS
$cshowsPrec :: Int -> ImportSortBy -> ShowS
Prelude.Show, forall x. Rep ImportSortBy x -> ImportSortBy
forall x. ImportSortBy -> Rep ImportSortBy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportSortBy x -> ImportSortBy
$cfrom :: forall x. ImportSortBy -> Rep ImportSortBy x
Prelude.Generic)

-- |
-- Create a value of 'ImportSortBy' 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', 'importSortBy_attribute' - The export field to use for sorting.
--
-- 'order', 'importSortBy_order' - The order to sort the list.
newImportSortBy ::
  -- | 'attribute'
  ImportSortAttribute ->
  -- | 'order'
  SortOrder ->
  ImportSortBy
newImportSortBy :: ImportSortAttribute -> SortOrder -> ImportSortBy
newImportSortBy ImportSortAttribute
pAttribute_ SortOrder
pOrder_ =
  ImportSortBy'
    { $sel:attribute:ImportSortBy' :: ImportSortAttribute
attribute = ImportSortAttribute
pAttribute_,
      $sel:order:ImportSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The export field to use for sorting.
importSortBy_attribute :: Lens.Lens' ImportSortBy ImportSortAttribute
importSortBy_attribute :: Lens' ImportSortBy ImportSortAttribute
importSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportSortBy' {ImportSortAttribute
attribute :: ImportSortAttribute
$sel:attribute:ImportSortBy' :: ImportSortBy -> ImportSortAttribute
attribute} -> ImportSortAttribute
attribute) (\s :: ImportSortBy
s@ImportSortBy' {} ImportSortAttribute
a -> ImportSortBy
s {$sel:attribute:ImportSortBy' :: ImportSortAttribute
attribute = ImportSortAttribute
a} :: ImportSortBy)

-- | The order to sort the list.
importSortBy_order :: Lens.Lens' ImportSortBy SortOrder
importSortBy_order :: Lens' ImportSortBy SortOrder
importSortBy_order = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportSortBy' {SortOrder
order :: SortOrder
$sel:order:ImportSortBy' :: ImportSortBy -> SortOrder
order} -> SortOrder
order) (\s :: ImportSortBy
s@ImportSortBy' {} SortOrder
a -> ImportSortBy
s {$sel:order:ImportSortBy' :: SortOrder
order = SortOrder
a} :: ImportSortBy)

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

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

instance Data.ToJSON ImportSortBy where
  toJSON :: ImportSortBy -> Value
toJSON ImportSortBy' {ImportSortAttribute
SortOrder
order :: SortOrder
attribute :: ImportSortAttribute
$sel:order:ImportSortBy' :: ImportSortBy -> SortOrder
$sel:attribute:ImportSortBy' :: ImportSortBy -> ImportSortAttribute
..} =
    [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..= ImportSortAttribute
attribute),
            forall a. a -> Maybe a
Prelude.Just (Key
"order" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SortOrder
order)
          ]
      )