{-# 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.AxisLinearScale
-- 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.AxisLinearScale 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

-- | The liner axis scale setup.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newAxisLinearScale' smart constructor.
data AxisLinearScale = AxisLinearScale'
  { -- | The step count setup of a linear axis.
    AxisLinearScale -> Maybe Int
stepCount :: Prelude.Maybe Prelude.Int,
    -- | The step size setup of a linear axis.
    AxisLinearScale -> Maybe Double
stepSize :: Prelude.Maybe Prelude.Double
  }
  deriving (AxisLinearScale -> AxisLinearScale -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AxisLinearScale -> AxisLinearScale -> Bool
$c/= :: AxisLinearScale -> AxisLinearScale -> Bool
== :: AxisLinearScale -> AxisLinearScale -> Bool
$c== :: AxisLinearScale -> AxisLinearScale -> Bool
Prelude.Eq, ReadPrec [AxisLinearScale]
ReadPrec AxisLinearScale
Int -> ReadS AxisLinearScale
ReadS [AxisLinearScale]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AxisLinearScale]
$creadListPrec :: ReadPrec [AxisLinearScale]
readPrec :: ReadPrec AxisLinearScale
$creadPrec :: ReadPrec AxisLinearScale
readList :: ReadS [AxisLinearScale]
$creadList :: ReadS [AxisLinearScale]
readsPrec :: Int -> ReadS AxisLinearScale
$creadsPrec :: Int -> ReadS AxisLinearScale
Prelude.Read, Int -> AxisLinearScale -> ShowS
[AxisLinearScale] -> ShowS
AxisLinearScale -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AxisLinearScale] -> ShowS
$cshowList :: [AxisLinearScale] -> ShowS
show :: AxisLinearScale -> String
$cshow :: AxisLinearScale -> String
showsPrec :: Int -> AxisLinearScale -> ShowS
$cshowsPrec :: Int -> AxisLinearScale -> ShowS
Prelude.Show, forall x. Rep AxisLinearScale x -> AxisLinearScale
forall x. AxisLinearScale -> Rep AxisLinearScale x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AxisLinearScale x -> AxisLinearScale
$cfrom :: forall x. AxisLinearScale -> Rep AxisLinearScale x
Prelude.Generic)

-- |
-- Create a value of 'AxisLinearScale' 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:
--
-- 'stepCount', 'axisLinearScale_stepCount' - The step count setup of a linear axis.
--
-- 'stepSize', 'axisLinearScale_stepSize' - The step size setup of a linear axis.
newAxisLinearScale ::
  AxisLinearScale
newAxisLinearScale :: AxisLinearScale
newAxisLinearScale =
  AxisLinearScale'
    { $sel:stepCount:AxisLinearScale' :: Maybe Int
stepCount = forall a. Maybe a
Prelude.Nothing,
      $sel:stepSize:AxisLinearScale' :: Maybe Double
stepSize = forall a. Maybe a
Prelude.Nothing
    }

-- | The step count setup of a linear axis.
axisLinearScale_stepCount :: Lens.Lens' AxisLinearScale (Prelude.Maybe Prelude.Int)
axisLinearScale_stepCount :: Lens' AxisLinearScale (Maybe Int)
axisLinearScale_stepCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AxisLinearScale' {Maybe Int
stepCount :: Maybe Int
$sel:stepCount:AxisLinearScale' :: AxisLinearScale -> Maybe Int
stepCount} -> Maybe Int
stepCount) (\s :: AxisLinearScale
s@AxisLinearScale' {} Maybe Int
a -> AxisLinearScale
s {$sel:stepCount:AxisLinearScale' :: Maybe Int
stepCount = Maybe Int
a} :: AxisLinearScale)

-- | The step size setup of a linear axis.
axisLinearScale_stepSize :: Lens.Lens' AxisLinearScale (Prelude.Maybe Prelude.Double)
axisLinearScale_stepSize :: Lens' AxisLinearScale (Maybe Double)
axisLinearScale_stepSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AxisLinearScale' {Maybe Double
stepSize :: Maybe Double
$sel:stepSize:AxisLinearScale' :: AxisLinearScale -> Maybe Double
stepSize} -> Maybe Double
stepSize) (\s :: AxisLinearScale
s@AxisLinearScale' {} Maybe Double
a -> AxisLinearScale
s {$sel:stepSize:AxisLinearScale' :: Maybe Double
stepSize = Maybe Double
a} :: AxisLinearScale)

instance Data.FromJSON AxisLinearScale where
  parseJSON :: Value -> Parser AxisLinearScale
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AxisLinearScale"
      ( \Object
x ->
          Maybe Int -> Maybe Double -> AxisLinearScale
AxisLinearScale'
            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
"StepCount")
            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
"StepSize")
      )

instance Prelude.Hashable AxisLinearScale where
  hashWithSalt :: Int -> AxisLinearScale -> Int
hashWithSalt Int
_salt AxisLinearScale' {Maybe Double
Maybe Int
stepSize :: Maybe Double
stepCount :: Maybe Int
$sel:stepSize:AxisLinearScale' :: AxisLinearScale -> Maybe Double
$sel:stepCount:AxisLinearScale' :: AxisLinearScale -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
stepCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
stepSize

instance Prelude.NFData AxisLinearScale where
  rnf :: AxisLinearScale -> ()
rnf AxisLinearScale' {Maybe Double
Maybe Int
stepSize :: Maybe Double
stepCount :: Maybe Int
$sel:stepSize:AxisLinearScale' :: AxisLinearScale -> Maybe Double
$sel:stepCount:AxisLinearScale' :: AxisLinearScale -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
stepCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
stepSize

instance Data.ToJSON AxisLinearScale where
  toJSON :: AxisLinearScale -> Value
toJSON AxisLinearScale' {Maybe Double
Maybe Int
stepSize :: Maybe Double
stepCount :: Maybe Int
$sel:stepSize:AxisLinearScale' :: AxisLinearScale -> Maybe Double
$sel:stepCount:AxisLinearScale' :: AxisLinearScale -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StepCount" 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 Int
stepCount,
            (Key
"StepSize" 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 Double
stepSize
          ]
      )