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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A range of double values.
--
-- /See:/ 'newDoubleRange' smart constructor.
data DoubleRange = DoubleRange'
  { -- | The maximum value in the range.
    DoubleRange -> Maybe Double
to :: Prelude.Maybe Prelude.Double,
    -- | The minimum value in the range.
    DoubleRange -> Maybe Double
from :: Prelude.Maybe Prelude.Double
  }
  deriving (DoubleRange -> DoubleRange -> Bool
(DoubleRange -> DoubleRange -> Bool)
-> (DoubleRange -> DoubleRange -> Bool) -> Eq DoubleRange
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]
(Int -> ReadS DoubleRange)
-> ReadS [DoubleRange]
-> ReadPrec DoubleRange
-> ReadPrec [DoubleRange]
-> Read 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
(Int -> DoubleRange -> ShowS)
-> (DoubleRange -> String)
-> ([DoubleRange] -> ShowS)
-> Show DoubleRange
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. DoubleRange -> Rep DoubleRange x)
-> (forall x. Rep DoubleRange x -> DoubleRange)
-> Generic DoubleRange
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:
--
-- 'to', 'doubleRange_to' - The maximum value in the range.
--
-- 'from', 'doubleRange_from' - The minimum value in the range.
newDoubleRange ::
  DoubleRange
newDoubleRange :: DoubleRange
newDoubleRange =
  DoubleRange' :: Maybe Double -> Maybe Double -> DoubleRange
DoubleRange'
    { $sel:to:DoubleRange' :: Maybe Double
to = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:from:DoubleRange' :: Maybe Double
from = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum value in the range.
doubleRange_to :: Lens.Lens' DoubleRange (Prelude.Maybe Prelude.Double)
doubleRange_to :: (Maybe Double -> f (Maybe Double)) -> DoubleRange -> f DoubleRange
doubleRange_to = (DoubleRange -> Maybe Double)
-> (DoubleRange -> Maybe Double -> DoubleRange)
-> Lens DoubleRange DoubleRange (Maybe Double) (Maybe Double)
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)

-- | The minimum value in the range.
doubleRange_from :: Lens.Lens' DoubleRange (Prelude.Maybe Prelude.Double)
doubleRange_from :: (Maybe Double -> f (Maybe Double)) -> DoubleRange -> f DoubleRange
doubleRange_from = (DoubleRange -> Maybe Double)
-> (DoubleRange -> Maybe Double -> DoubleRange)
-> Lens DoubleRange DoubleRange (Maybe Double) (Maybe Double)
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)

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

instance Prelude.Hashable DoubleRange

instance Prelude.NFData DoubleRange