{-# 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.RDS.Types.DoubleRange
-- 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.RDS.Types.DoubleRange 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

-- | A range of double values.
--
-- /See:/ 'newDoubleRange' smart constructor.
data DoubleRange = DoubleRange'
  { -- | The minimum value in the range.
    DoubleRange -> Maybe Double
from :: Prelude.Maybe Prelude.Double,
    -- | The maximum value in the range.
    DoubleRange -> Maybe Double
to :: Prelude.Maybe Prelude.Double
  }
  deriving (DoubleRange -> DoubleRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DoubleRange -> DoubleRange -> Bool
$c/= :: DoubleRange -> DoubleRange -> Bool
== :: DoubleRange -> DoubleRange -> Bool
$c== :: DoubleRange -> DoubleRange -> Bool
Prelude.Eq, ReadPrec [DoubleRange]
ReadPrec DoubleRange
Int -> ReadS DoubleRange
ReadS [DoubleRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DoubleRange]
$creadListPrec :: ReadPrec [DoubleRange]
readPrec :: ReadPrec DoubleRange
$creadPrec :: ReadPrec DoubleRange
readList :: ReadS [DoubleRange]
$creadList :: ReadS [DoubleRange]
readsPrec :: Int -> ReadS DoubleRange
$creadsPrec :: Int -> ReadS DoubleRange
Prelude.Read, Int -> DoubleRange -> ShowS
[DoubleRange] -> ShowS
DoubleRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DoubleRange] -> ShowS
$cshowList :: [DoubleRange] -> ShowS
show :: DoubleRange -> String
$cshow :: DoubleRange -> String
showsPrec :: Int -> DoubleRange -> ShowS
$cshowsPrec :: Int -> DoubleRange -> ShowS
Prelude.Show, forall x. Rep DoubleRange x -> DoubleRange
forall x. DoubleRange -> Rep DoubleRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DoubleRange x -> DoubleRange
$cfrom :: forall x. DoubleRange -> Rep DoubleRange x
Prelude.Generic)

-- |
-- Create a value of 'DoubleRange' 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:
--
-- 'from', 'doubleRange_from' - The minimum value in the range.
--
-- 'to', 'doubleRange_to' - The maximum value in the range.
newDoubleRange ::
  DoubleRange
newDoubleRange :: DoubleRange
newDoubleRange =
  DoubleRange'
    { $sel:from:DoubleRange' :: Maybe Double
from = forall a. Maybe a
Prelude.Nothing,
      $sel:to:DoubleRange' :: Maybe Double
to = forall a. Maybe a
Prelude.Nothing
    }

-- | The minimum value in the range.
doubleRange_from :: Lens.Lens' DoubleRange (Prelude.Maybe Prelude.Double)
doubleRange_from :: Lens' DoubleRange (Maybe Double)
doubleRange_from = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleRange' {Maybe Double
from :: Maybe Double
$sel:from:DoubleRange' :: DoubleRange -> Maybe Double
from} -> Maybe Double
from) (\s :: DoubleRange
s@DoubleRange' {} Maybe Double
a -> DoubleRange
s {$sel:from:DoubleRange' :: Maybe Double
from = Maybe Double
a} :: DoubleRange)

-- | The maximum value in the range.
doubleRange_to :: Lens.Lens' DoubleRange (Prelude.Maybe Prelude.Double)
doubleRange_to :: Lens' DoubleRange (Maybe Double)
doubleRange_to = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleRange' {Maybe Double
to :: Maybe Double
$sel:to:DoubleRange' :: DoubleRange -> Maybe Double
to} -> Maybe Double
to) (\s :: DoubleRange
s@DoubleRange' {} Maybe Double
a -> DoubleRange
s {$sel:to:DoubleRange' :: Maybe Double
to = Maybe Double
a} :: DoubleRange)

instance Data.FromXML DoubleRange where
  parseXML :: [Node] -> Either String DoubleRange
parseXML [Node]
x =
    Maybe Double -> Maybe Double -> DoubleRange
DoubleRange'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"From")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"To")

instance Prelude.Hashable DoubleRange where
  hashWithSalt :: Int -> DoubleRange -> Int
hashWithSalt Int
_salt DoubleRange' {Maybe Double
to :: Maybe Double
from :: Maybe Double
$sel:to:DoubleRange' :: DoubleRange -> Maybe Double
$sel:from:DoubleRange' :: DoubleRange -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
from
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
to

instance Prelude.NFData DoubleRange where
  rnf :: DoubleRange -> ()
rnf DoubleRange' {Maybe Double
to :: Maybe Double
from :: Maybe Double
$sel:to:DoubleRange' :: DoubleRange -> Maybe Double
$sel:from:DoubleRange' :: DoubleRange -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
from seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
to