{-# 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.RDSData.Types.ResultSetOptions
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RDSData.Types.ResultSetOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDSData.Types.DecimalReturnType

-- | Options that control how the result set is returned.
--
-- /See:/ 'newResultSetOptions' smart constructor.
data ResultSetOptions = ResultSetOptions'
  { -- | A value that indicates how a field of @DECIMAL@ type is represented in
    -- the response. The value of @STRING@, the default, specifies that it is
    -- converted to a String value. The value of @DOUBLE_OR_LONG@ specifies
    -- that it is converted to a Long value if its scale is 0, or to a Double
    -- value otherwise.
    --
    -- Conversion to Double or Long can result in roundoff errors due to
    -- precision loss. We recommend converting to String, especially when
    -- working with currency values.
    ResultSetOptions -> Maybe DecimalReturnType
decimalReturnType :: Prelude.Maybe DecimalReturnType
  }
  deriving (ResultSetOptions -> ResultSetOptions -> Bool
(ResultSetOptions -> ResultSetOptions -> Bool)
-> (ResultSetOptions -> ResultSetOptions -> Bool)
-> Eq ResultSetOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultSetOptions -> ResultSetOptions -> Bool
$c/= :: ResultSetOptions -> ResultSetOptions -> Bool
== :: ResultSetOptions -> ResultSetOptions -> Bool
$c== :: ResultSetOptions -> ResultSetOptions -> Bool
Prelude.Eq, ReadPrec [ResultSetOptions]
ReadPrec ResultSetOptions
Int -> ReadS ResultSetOptions
ReadS [ResultSetOptions]
(Int -> ReadS ResultSetOptions)
-> ReadS [ResultSetOptions]
-> ReadPrec ResultSetOptions
-> ReadPrec [ResultSetOptions]
-> Read ResultSetOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResultSetOptions]
$creadListPrec :: ReadPrec [ResultSetOptions]
readPrec :: ReadPrec ResultSetOptions
$creadPrec :: ReadPrec ResultSetOptions
readList :: ReadS [ResultSetOptions]
$creadList :: ReadS [ResultSetOptions]
readsPrec :: Int -> ReadS ResultSetOptions
$creadsPrec :: Int -> ReadS ResultSetOptions
Prelude.Read, Int -> ResultSetOptions -> ShowS
[ResultSetOptions] -> ShowS
ResultSetOptions -> String
(Int -> ResultSetOptions -> ShowS)
-> (ResultSetOptions -> String)
-> ([ResultSetOptions] -> ShowS)
-> Show ResultSetOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultSetOptions] -> ShowS
$cshowList :: [ResultSetOptions] -> ShowS
show :: ResultSetOptions -> String
$cshow :: ResultSetOptions -> String
showsPrec :: Int -> ResultSetOptions -> ShowS
$cshowsPrec :: Int -> ResultSetOptions -> ShowS
Prelude.Show, (forall x. ResultSetOptions -> Rep ResultSetOptions x)
-> (forall x. Rep ResultSetOptions x -> ResultSetOptions)
-> Generic ResultSetOptions
forall x. Rep ResultSetOptions x -> ResultSetOptions
forall x. ResultSetOptions -> Rep ResultSetOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultSetOptions x -> ResultSetOptions
$cfrom :: forall x. ResultSetOptions -> Rep ResultSetOptions x
Prelude.Generic)

-- |
-- Create a value of 'ResultSetOptions' 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:
--
-- 'decimalReturnType', 'resultSetOptions_decimalReturnType' - A value that indicates how a field of @DECIMAL@ type is represented in
-- the response. The value of @STRING@, the default, specifies that it is
-- converted to a String value. The value of @DOUBLE_OR_LONG@ specifies
-- that it is converted to a Long value if its scale is 0, or to a Double
-- value otherwise.
--
-- Conversion to Double or Long can result in roundoff errors due to
-- precision loss. We recommend converting to String, especially when
-- working with currency values.
newResultSetOptions ::
  ResultSetOptions
newResultSetOptions :: ResultSetOptions
newResultSetOptions =
  ResultSetOptions' :: Maybe DecimalReturnType -> ResultSetOptions
ResultSetOptions'
    { $sel:decimalReturnType:ResultSetOptions' :: Maybe DecimalReturnType
decimalReturnType =
        Maybe DecimalReturnType
forall a. Maybe a
Prelude.Nothing
    }

-- | A value that indicates how a field of @DECIMAL@ type is represented in
-- the response. The value of @STRING@, the default, specifies that it is
-- converted to a String value. The value of @DOUBLE_OR_LONG@ specifies
-- that it is converted to a Long value if its scale is 0, or to a Double
-- value otherwise.
--
-- Conversion to Double or Long can result in roundoff errors due to
-- precision loss. We recommend converting to String, especially when
-- working with currency values.
resultSetOptions_decimalReturnType :: Lens.Lens' ResultSetOptions (Prelude.Maybe DecimalReturnType)
resultSetOptions_decimalReturnType :: (Maybe DecimalReturnType -> f (Maybe DecimalReturnType))
-> ResultSetOptions -> f ResultSetOptions
resultSetOptions_decimalReturnType = (ResultSetOptions -> Maybe DecimalReturnType)
-> (ResultSetOptions
    -> Maybe DecimalReturnType -> ResultSetOptions)
-> Lens
     ResultSetOptions
     ResultSetOptions
     (Maybe DecimalReturnType)
     (Maybe DecimalReturnType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultSetOptions' {Maybe DecimalReturnType
decimalReturnType :: Maybe DecimalReturnType
$sel:decimalReturnType:ResultSetOptions' :: ResultSetOptions -> Maybe DecimalReturnType
decimalReturnType} -> Maybe DecimalReturnType
decimalReturnType) (\s :: ResultSetOptions
s@ResultSetOptions' {} Maybe DecimalReturnType
a -> ResultSetOptions
s {$sel:decimalReturnType:ResultSetOptions' :: Maybe DecimalReturnType
decimalReturnType = Maybe DecimalReturnType
a} :: ResultSetOptions)

instance Prelude.Hashable ResultSetOptions

instance Prelude.NFData ResultSetOptions

instance Core.ToJSON ResultSetOptions where
  toJSON :: ResultSetOptions -> Value
toJSON ResultSetOptions' {Maybe DecimalReturnType
decimalReturnType :: Maybe DecimalReturnType
$sel:decimalReturnType:ResultSetOptions' :: ResultSetOptions -> Maybe DecimalReturnType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"decimalReturnType" Text -> DecimalReturnType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DecimalReturnType -> Pair)
-> Maybe DecimalReturnType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DecimalReturnType
decimalReturnType
          ]
      )