{-# 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.TreeMapSortConfiguration
-- 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.TreeMapSortConfiguration 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.ItemsLimitConfiguration

-- | The sort configuration of a tree map.
--
-- /See:/ 'newTreeMapSortConfiguration' smart constructor.
data TreeMapSortConfiguration = TreeMapSortConfiguration'
  { -- | The limit on the number of groups that are displayed.
    TreeMapSortConfiguration -> Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration :: Prelude.Maybe ItemsLimitConfiguration,
    -- | The sort configuration of group by fields.
    TreeMapSortConfiguration -> Maybe [FieldSortOptions]
treeMapSort :: Prelude.Maybe [FieldSortOptions]
  }
  deriving (TreeMapSortConfiguration -> TreeMapSortConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TreeMapSortConfiguration -> TreeMapSortConfiguration -> Bool
$c/= :: TreeMapSortConfiguration -> TreeMapSortConfiguration -> Bool
== :: TreeMapSortConfiguration -> TreeMapSortConfiguration -> Bool
$c== :: TreeMapSortConfiguration -> TreeMapSortConfiguration -> Bool
Prelude.Eq, ReadPrec [TreeMapSortConfiguration]
ReadPrec TreeMapSortConfiguration
Int -> ReadS TreeMapSortConfiguration
ReadS [TreeMapSortConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TreeMapSortConfiguration]
$creadListPrec :: ReadPrec [TreeMapSortConfiguration]
readPrec :: ReadPrec TreeMapSortConfiguration
$creadPrec :: ReadPrec TreeMapSortConfiguration
readList :: ReadS [TreeMapSortConfiguration]
$creadList :: ReadS [TreeMapSortConfiguration]
readsPrec :: Int -> ReadS TreeMapSortConfiguration
$creadsPrec :: Int -> ReadS TreeMapSortConfiguration
Prelude.Read, Int -> TreeMapSortConfiguration -> ShowS
[TreeMapSortConfiguration] -> ShowS
TreeMapSortConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TreeMapSortConfiguration] -> ShowS
$cshowList :: [TreeMapSortConfiguration] -> ShowS
show :: TreeMapSortConfiguration -> String
$cshow :: TreeMapSortConfiguration -> String
showsPrec :: Int -> TreeMapSortConfiguration -> ShowS
$cshowsPrec :: Int -> TreeMapSortConfiguration -> ShowS
Prelude.Show, forall x.
Rep TreeMapSortConfiguration x -> TreeMapSortConfiguration
forall x.
TreeMapSortConfiguration -> Rep TreeMapSortConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TreeMapSortConfiguration x -> TreeMapSortConfiguration
$cfrom :: forall x.
TreeMapSortConfiguration -> Rep TreeMapSortConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TreeMapSortConfiguration' 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:
--
-- 'treeMapGroupItemsLimitConfiguration', 'treeMapSortConfiguration_treeMapGroupItemsLimitConfiguration' - The limit on the number of groups that are displayed.
--
-- 'treeMapSort', 'treeMapSortConfiguration_treeMapSort' - The sort configuration of group by fields.
newTreeMapSortConfiguration ::
  TreeMapSortConfiguration
newTreeMapSortConfiguration :: TreeMapSortConfiguration
newTreeMapSortConfiguration =
  TreeMapSortConfiguration'
    { $sel:treeMapGroupItemsLimitConfiguration:TreeMapSortConfiguration' :: Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:treeMapSort:TreeMapSortConfiguration' :: Maybe [FieldSortOptions]
treeMapSort = forall a. Maybe a
Prelude.Nothing
    }

-- | The limit on the number of groups that are displayed.
treeMapSortConfiguration_treeMapGroupItemsLimitConfiguration :: Lens.Lens' TreeMapSortConfiguration (Prelude.Maybe ItemsLimitConfiguration)
treeMapSortConfiguration_treeMapGroupItemsLimitConfiguration :: Lens' TreeMapSortConfiguration (Maybe ItemsLimitConfiguration)
treeMapSortConfiguration_treeMapGroupItemsLimitConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TreeMapSortConfiguration' {Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration :: Maybe ItemsLimitConfiguration
$sel:treeMapGroupItemsLimitConfiguration:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration} -> Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration) (\s :: TreeMapSortConfiguration
s@TreeMapSortConfiguration' {} Maybe ItemsLimitConfiguration
a -> TreeMapSortConfiguration
s {$sel:treeMapGroupItemsLimitConfiguration:TreeMapSortConfiguration' :: Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration = Maybe ItemsLimitConfiguration
a} :: TreeMapSortConfiguration)

-- | The sort configuration of group by fields.
treeMapSortConfiguration_treeMapSort :: Lens.Lens' TreeMapSortConfiguration (Prelude.Maybe [FieldSortOptions])
treeMapSortConfiguration_treeMapSort :: Lens' TreeMapSortConfiguration (Maybe [FieldSortOptions])
treeMapSortConfiguration_treeMapSort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TreeMapSortConfiguration' {Maybe [FieldSortOptions]
treeMapSort :: Maybe [FieldSortOptions]
$sel:treeMapSort:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe [FieldSortOptions]
treeMapSort} -> Maybe [FieldSortOptions]
treeMapSort) (\s :: TreeMapSortConfiguration
s@TreeMapSortConfiguration' {} Maybe [FieldSortOptions]
a -> TreeMapSortConfiguration
s {$sel:treeMapSort:TreeMapSortConfiguration' :: Maybe [FieldSortOptions]
treeMapSort = Maybe [FieldSortOptions]
a} :: TreeMapSortConfiguration) 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

instance Data.FromJSON TreeMapSortConfiguration where
  parseJSON :: Value -> Parser TreeMapSortConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TreeMapSortConfiguration"
      ( \Object
x ->
          Maybe ItemsLimitConfiguration
-> Maybe [FieldSortOptions] -> TreeMapSortConfiguration
TreeMapSortConfiguration'
            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
"TreeMapGroupItemsLimitConfiguration")
            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
"TreeMapSort" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TreeMapSortConfiguration where
  hashWithSalt :: Int -> TreeMapSortConfiguration -> Int
hashWithSalt Int
_salt TreeMapSortConfiguration' {Maybe [FieldSortOptions]
Maybe ItemsLimitConfiguration
treeMapSort :: Maybe [FieldSortOptions]
treeMapGroupItemsLimitConfiguration :: Maybe ItemsLimitConfiguration
$sel:treeMapSort:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe [FieldSortOptions]
$sel:treeMapGroupItemsLimitConfiguration:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe ItemsLimitConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [FieldSortOptions]
treeMapSort

instance Prelude.NFData TreeMapSortConfiguration where
  rnf :: TreeMapSortConfiguration -> ()
rnf TreeMapSortConfiguration' {Maybe [FieldSortOptions]
Maybe ItemsLimitConfiguration
treeMapSort :: Maybe [FieldSortOptions]
treeMapGroupItemsLimitConfiguration :: Maybe ItemsLimitConfiguration
$sel:treeMapSort:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe [FieldSortOptions]
$sel:treeMapGroupItemsLimitConfiguration:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe ItemsLimitConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [FieldSortOptions]
treeMapSort

instance Data.ToJSON TreeMapSortConfiguration where
  toJSON :: TreeMapSortConfiguration -> Value
toJSON TreeMapSortConfiguration' {Maybe [FieldSortOptions]
Maybe ItemsLimitConfiguration
treeMapSort :: Maybe [FieldSortOptions]
treeMapGroupItemsLimitConfiguration :: Maybe ItemsLimitConfiguration
$sel:treeMapSort:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe [FieldSortOptions]
$sel:treeMapGroupItemsLimitConfiguration:TreeMapSortConfiguration' :: TreeMapSortConfiguration -> Maybe ItemsLimitConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TreeMapGroupItemsLimitConfiguration" 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 ItemsLimitConfiguration
treeMapGroupItemsLimitConfiguration,
            (Key
"TreeMapSort" 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]
treeMapSort
          ]
      )