{-# 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.QuickSight.Types.BoxPlotSortConfiguration
-- 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.QuickSight.Types.BoxPlotSortConfiguration 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.FieldSortOptions
import Amazonka.QuickSight.Types.PaginationConfiguration

-- | The sort configuration of a @BoxPlotVisual@.
--
-- /See:/ 'newBoxPlotSortConfiguration' smart constructor.
data BoxPlotSortConfiguration = BoxPlotSortConfiguration'
  { -- | The sort configuration of a group by fields.
    BoxPlotSortConfiguration -> Maybe [FieldSortOptions]
categorySort :: Prelude.Maybe [FieldSortOptions],
    -- | The pagination configuration of a table visual or box plot.
    BoxPlotSortConfiguration -> Maybe PaginationConfiguration
paginationConfiguration :: Prelude.Maybe PaginationConfiguration
  }
  deriving (BoxPlotSortConfiguration -> BoxPlotSortConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BoxPlotSortConfiguration -> BoxPlotSortConfiguration -> Bool
$c/= :: BoxPlotSortConfiguration -> BoxPlotSortConfiguration -> Bool
== :: BoxPlotSortConfiguration -> BoxPlotSortConfiguration -> Bool
$c== :: BoxPlotSortConfiguration -> BoxPlotSortConfiguration -> Bool
Prelude.Eq, ReadPrec [BoxPlotSortConfiguration]
ReadPrec BoxPlotSortConfiguration
Int -> ReadS BoxPlotSortConfiguration
ReadS [BoxPlotSortConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BoxPlotSortConfiguration]
$creadListPrec :: ReadPrec [BoxPlotSortConfiguration]
readPrec :: ReadPrec BoxPlotSortConfiguration
$creadPrec :: ReadPrec BoxPlotSortConfiguration
readList :: ReadS [BoxPlotSortConfiguration]
$creadList :: ReadS [BoxPlotSortConfiguration]
readsPrec :: Int -> ReadS BoxPlotSortConfiguration
$creadsPrec :: Int -> ReadS BoxPlotSortConfiguration
Prelude.Read, Int -> BoxPlotSortConfiguration -> ShowS
[BoxPlotSortConfiguration] -> ShowS
BoxPlotSortConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BoxPlotSortConfiguration] -> ShowS
$cshowList :: [BoxPlotSortConfiguration] -> ShowS
show :: BoxPlotSortConfiguration -> String
$cshow :: BoxPlotSortConfiguration -> String
showsPrec :: Int -> BoxPlotSortConfiguration -> ShowS
$cshowsPrec :: Int -> BoxPlotSortConfiguration -> ShowS
Prelude.Show, forall x.
Rep BoxPlotSortConfiguration x -> BoxPlotSortConfiguration
forall x.
BoxPlotSortConfiguration -> Rep BoxPlotSortConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BoxPlotSortConfiguration x -> BoxPlotSortConfiguration
$cfrom :: forall x.
BoxPlotSortConfiguration -> Rep BoxPlotSortConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'BoxPlotSortConfiguration' 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:
--
-- 'categorySort', 'boxPlotSortConfiguration_categorySort' - The sort configuration of a group by fields.
--
-- 'paginationConfiguration', 'boxPlotSortConfiguration_paginationConfiguration' - The pagination configuration of a table visual or box plot.
newBoxPlotSortConfiguration ::
  BoxPlotSortConfiguration
newBoxPlotSortConfiguration :: BoxPlotSortConfiguration
newBoxPlotSortConfiguration =
  BoxPlotSortConfiguration'
    { $sel:categorySort:BoxPlotSortConfiguration' :: Maybe [FieldSortOptions]
categorySort =
        forall a. Maybe a
Prelude.Nothing,
      $sel:paginationConfiguration:BoxPlotSortConfiguration' :: Maybe PaginationConfiguration
paginationConfiguration = forall a. Maybe a
Prelude.Nothing
    }

-- | The sort configuration of a group by fields.
boxPlotSortConfiguration_categorySort :: Lens.Lens' BoxPlotSortConfiguration (Prelude.Maybe [FieldSortOptions])
boxPlotSortConfiguration_categorySort :: Lens' BoxPlotSortConfiguration (Maybe [FieldSortOptions])
boxPlotSortConfiguration_categorySort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BoxPlotSortConfiguration' {Maybe [FieldSortOptions]
categorySort :: Maybe [FieldSortOptions]
$sel:categorySort:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe [FieldSortOptions]
categorySort} -> Maybe [FieldSortOptions]
categorySort) (\s :: BoxPlotSortConfiguration
s@BoxPlotSortConfiguration' {} Maybe [FieldSortOptions]
a -> BoxPlotSortConfiguration
s {$sel:categorySort:BoxPlotSortConfiguration' :: Maybe [FieldSortOptions]
categorySort = Maybe [FieldSortOptions]
a} :: BoxPlotSortConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination configuration of a table visual or box plot.
boxPlotSortConfiguration_paginationConfiguration :: Lens.Lens' BoxPlotSortConfiguration (Prelude.Maybe PaginationConfiguration)
boxPlotSortConfiguration_paginationConfiguration :: Lens' BoxPlotSortConfiguration (Maybe PaginationConfiguration)
boxPlotSortConfiguration_paginationConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BoxPlotSortConfiguration' {Maybe PaginationConfiguration
paginationConfiguration :: Maybe PaginationConfiguration
$sel:paginationConfiguration:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe PaginationConfiguration
paginationConfiguration} -> Maybe PaginationConfiguration
paginationConfiguration) (\s :: BoxPlotSortConfiguration
s@BoxPlotSortConfiguration' {} Maybe PaginationConfiguration
a -> BoxPlotSortConfiguration
s {$sel:paginationConfiguration:BoxPlotSortConfiguration' :: Maybe PaginationConfiguration
paginationConfiguration = Maybe PaginationConfiguration
a} :: BoxPlotSortConfiguration)

instance Data.FromJSON BoxPlotSortConfiguration where
  parseJSON :: Value -> Parser BoxPlotSortConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BoxPlotSortConfiguration"
      ( \Object
x ->
          Maybe [FieldSortOptions]
-> Maybe PaginationConfiguration -> BoxPlotSortConfiguration
BoxPlotSortConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CategorySort" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"PaginationConfiguration")
      )

instance Prelude.Hashable BoxPlotSortConfiguration where
  hashWithSalt :: Int -> BoxPlotSortConfiguration -> Int
hashWithSalt Int
_salt BoxPlotSortConfiguration' {Maybe [FieldSortOptions]
Maybe PaginationConfiguration
paginationConfiguration :: Maybe PaginationConfiguration
categorySort :: Maybe [FieldSortOptions]
$sel:paginationConfiguration:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe PaginationConfiguration
$sel:categorySort:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe [FieldSortOptions]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [FieldSortOptions]
categorySort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PaginationConfiguration
paginationConfiguration

instance Prelude.NFData BoxPlotSortConfiguration where
  rnf :: BoxPlotSortConfiguration -> ()
rnf BoxPlotSortConfiguration' {Maybe [FieldSortOptions]
Maybe PaginationConfiguration
paginationConfiguration :: Maybe PaginationConfiguration
categorySort :: Maybe [FieldSortOptions]
$sel:paginationConfiguration:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe PaginationConfiguration
$sel:categorySort:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe [FieldSortOptions]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FieldSortOptions]
categorySort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PaginationConfiguration
paginationConfiguration

instance Data.ToJSON BoxPlotSortConfiguration where
  toJSON :: BoxPlotSortConfiguration -> Value
toJSON BoxPlotSortConfiguration' {Maybe [FieldSortOptions]
Maybe PaginationConfiguration
paginationConfiguration :: Maybe PaginationConfiguration
categorySort :: Maybe [FieldSortOptions]
$sel:paginationConfiguration:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe PaginationConfiguration
$sel:categorySort:BoxPlotSortConfiguration' :: BoxPlotSortConfiguration -> Maybe [FieldSortOptions]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CategorySort" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [FieldSortOptions]
categorySort,
            (Key
"PaginationConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PaginationConfiguration
paginationConfiguration
          ]
      )