{-# 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.QuickSight.Types.FieldSort 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
import Amazonka.QuickSight.Types.SortDirection
data FieldSort = FieldSort'
{
FieldSort -> Text
fieldId :: Prelude.Text,
FieldSort -> SortDirection
direction :: SortDirection
}
deriving (FieldSort -> FieldSort -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldSort -> FieldSort -> Bool
$c/= :: FieldSort -> FieldSort -> Bool
== :: FieldSort -> FieldSort -> Bool
$c== :: FieldSort -> FieldSort -> Bool
Prelude.Eq, ReadPrec [FieldSort]
ReadPrec FieldSort
Int -> ReadS FieldSort
ReadS [FieldSort]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldSort]
$creadListPrec :: ReadPrec [FieldSort]
readPrec :: ReadPrec FieldSort
$creadPrec :: ReadPrec FieldSort
readList :: ReadS [FieldSort]
$creadList :: ReadS [FieldSort]
readsPrec :: Int -> ReadS FieldSort
$creadsPrec :: Int -> ReadS FieldSort
Prelude.Read, Int -> FieldSort -> ShowS
[FieldSort] -> ShowS
FieldSort -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldSort] -> ShowS
$cshowList :: [FieldSort] -> ShowS
show :: FieldSort -> String
$cshow :: FieldSort -> String
showsPrec :: Int -> FieldSort -> ShowS
$cshowsPrec :: Int -> FieldSort -> ShowS
Prelude.Show, forall x. Rep FieldSort x -> FieldSort
forall x. FieldSort -> Rep FieldSort x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FieldSort x -> FieldSort
$cfrom :: forall x. FieldSort -> Rep FieldSort x
Prelude.Generic)
newFieldSort ::
Prelude.Text ->
SortDirection ->
FieldSort
newFieldSort :: Text -> SortDirection -> FieldSort
newFieldSort Text
pFieldId_ SortDirection
pDirection_ =
FieldSort'
{ $sel:fieldId:FieldSort' :: Text
fieldId = Text
pFieldId_,
$sel:direction:FieldSort' :: SortDirection
direction = SortDirection
pDirection_
}
fieldSort_fieldId :: Lens.Lens' FieldSort Prelude.Text
fieldSort_fieldId :: Lens' FieldSort Text
fieldSort_fieldId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldSort' {Text
fieldId :: Text
$sel:fieldId:FieldSort' :: FieldSort -> Text
fieldId} -> Text
fieldId) (\s :: FieldSort
s@FieldSort' {} Text
a -> FieldSort
s {$sel:fieldId:FieldSort' :: Text
fieldId = Text
a} :: FieldSort)
fieldSort_direction :: Lens.Lens' FieldSort SortDirection
fieldSort_direction :: Lens' FieldSort SortDirection
fieldSort_direction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldSort' {SortDirection
direction :: SortDirection
$sel:direction:FieldSort' :: FieldSort -> SortDirection
direction} -> SortDirection
direction) (\s :: FieldSort
s@FieldSort' {} SortDirection
a -> FieldSort
s {$sel:direction:FieldSort' :: SortDirection
direction = SortDirection
a} :: FieldSort)
instance Data.FromJSON FieldSort where
parseJSON :: Value -> Parser FieldSort
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"FieldSort"
( \Object
x ->
Text -> SortDirection -> FieldSort
FieldSort'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FieldId")
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
"Direction")
)
instance Prelude.Hashable FieldSort where
hashWithSalt :: Int -> FieldSort -> Int
hashWithSalt Int
_salt FieldSort' {Text
SortDirection
direction :: SortDirection
fieldId :: Text
$sel:direction:FieldSort' :: FieldSort -> SortDirection
$sel:fieldId:FieldSort' :: FieldSort -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fieldId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SortDirection
direction
instance Prelude.NFData FieldSort where
rnf :: FieldSort -> ()
rnf FieldSort' {Text
SortDirection
direction :: SortDirection
fieldId :: Text
$sel:direction:FieldSort' :: FieldSort -> SortDirection
$sel:fieldId:FieldSort' :: FieldSort -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
fieldId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SortDirection
direction
instance Data.ToJSON FieldSort where
toJSON :: FieldSort -> Value
toJSON FieldSort' {Text
SortDirection
direction :: SortDirection
fieldId :: Text
$sel:direction:FieldSort' :: FieldSort -> SortDirection
$sel:fieldId:FieldSort' :: FieldSort -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"FieldId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fieldId),
forall a. a -> Maybe a
Prelude.Just (Key
"Direction" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SortDirection
direction)
]
)