{-# 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.AlexaBusiness.Types.Sort where
import Amazonka.AlexaBusiness.Types.SortValue
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Sort = Sort'
{
Sort -> Text
key :: Prelude.Text,
Sort -> SortValue
value :: SortValue
}
deriving (Sort -> Sort -> Bool
(Sort -> Sort -> Bool) -> (Sort -> Sort -> Bool) -> Eq Sort
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sort -> Sort -> Bool
$c/= :: Sort -> Sort -> Bool
== :: Sort -> Sort -> Bool
$c== :: Sort -> Sort -> Bool
Prelude.Eq, ReadPrec [Sort]
ReadPrec Sort
Int -> ReadS Sort
ReadS [Sort]
(Int -> ReadS Sort)
-> ReadS [Sort] -> ReadPrec Sort -> ReadPrec [Sort] -> Read Sort
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Sort]
$creadListPrec :: ReadPrec [Sort]
readPrec :: ReadPrec Sort
$creadPrec :: ReadPrec Sort
readList :: ReadS [Sort]
$creadList :: ReadS [Sort]
readsPrec :: Int -> ReadS Sort
$creadsPrec :: Int -> ReadS Sort
Prelude.Read, Int -> Sort -> ShowS
[Sort] -> ShowS
Sort -> String
(Int -> Sort -> ShowS)
-> (Sort -> String) -> ([Sort] -> ShowS) -> Show Sort
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sort] -> ShowS
$cshowList :: [Sort] -> ShowS
show :: Sort -> String
$cshow :: Sort -> String
showsPrec :: Int -> Sort -> ShowS
$cshowsPrec :: Int -> Sort -> ShowS
Prelude.Show, (forall x. Sort -> Rep Sort x)
-> (forall x. Rep Sort x -> Sort) -> Generic Sort
forall x. Rep Sort x -> Sort
forall x. Sort -> Rep Sort x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Sort x -> Sort
$cfrom :: forall x. Sort -> Rep Sort x
Prelude.Generic)
newSort ::
Prelude.Text ->
SortValue ->
Sort
newSort :: Text -> SortValue -> Sort
newSort Text
pKey_ SortValue
pValue_ =
Sort' :: Text -> SortValue -> Sort
Sort' {$sel:key:Sort' :: Text
key = Text
pKey_, $sel:value:Sort' :: SortValue
value = SortValue
pValue_}
sort_key :: Lens.Lens' Sort Prelude.Text
sort_key :: (Text -> f Text) -> Sort -> f Sort
sort_key = (Sort -> Text)
-> (Sort -> Text -> Sort) -> Lens Sort Sort Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sort' {Text
key :: Text
$sel:key:Sort' :: Sort -> Text
key} -> Text
key) (\s :: Sort
s@Sort' {} Text
a -> Sort
s {$sel:key:Sort' :: Text
key = Text
a} :: Sort)
sort_value :: Lens.Lens' Sort SortValue
sort_value :: (SortValue -> f SortValue) -> Sort -> f Sort
sort_value = (Sort -> SortValue)
-> (Sort -> SortValue -> Sort)
-> Lens Sort Sort SortValue SortValue
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sort' {SortValue
value :: SortValue
$sel:value:Sort' :: Sort -> SortValue
value} -> SortValue
value) (\s :: Sort
s@Sort' {} SortValue
a -> Sort
s {$sel:value:Sort' :: SortValue
value = SortValue
a} :: Sort)
instance Prelude.Hashable Sort
instance Prelude.NFData Sort
instance Core.ToJSON Sort where
toJSON :: Sort -> Value
toJSON Sort' {Text
SortValue
value :: SortValue
key :: Text
$sel:value:Sort' :: Sort -> SortValue
$sel:key:Sort' :: Sort -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> SortValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SortValue
value)
]
)