{-# 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.CloudSearch.Types.DoubleOptions
-- 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.CloudSearch.Types.DoubleOptions where

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

-- | Options for a double-precision 64-bit floating point field. Present if
-- @IndexFieldType@ specifies the field is of type @double@. All options
-- are enabled by default.
--
-- /See:/ 'newDoubleOptions' smart constructor.
data DoubleOptions = DoubleOptions'
  { -- | The name of the source field to map to the field.
    DoubleOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text,
    -- | Whether the contents of the field can be returned in the search results.
    DoubleOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether facet information can be returned for the field.
    DoubleOptions -> Maybe Bool
facetEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field are searchable.
    DoubleOptions -> Maybe Bool
searchEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the field can be used to sort the search results.
    DoubleOptions -> Maybe Bool
sortEnabled :: Prelude.Maybe Prelude.Bool,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document. This can be important if you are using the field in an
    -- expression and that field is not present in every document.
    DoubleOptions -> Maybe Double
defaultValue :: Prelude.Maybe Prelude.Double
  }
  deriving (DoubleOptions -> DoubleOptions -> Bool
(DoubleOptions -> DoubleOptions -> Bool)
-> (DoubleOptions -> DoubleOptions -> Bool) -> Eq DoubleOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DoubleOptions -> DoubleOptions -> Bool
$c/= :: DoubleOptions -> DoubleOptions -> Bool
== :: DoubleOptions -> DoubleOptions -> Bool
$c== :: DoubleOptions -> DoubleOptions -> Bool
Prelude.Eq, ReadPrec [DoubleOptions]
ReadPrec DoubleOptions
Int -> ReadS DoubleOptions
ReadS [DoubleOptions]
(Int -> ReadS DoubleOptions)
-> ReadS [DoubleOptions]
-> ReadPrec DoubleOptions
-> ReadPrec [DoubleOptions]
-> Read DoubleOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DoubleOptions]
$creadListPrec :: ReadPrec [DoubleOptions]
readPrec :: ReadPrec DoubleOptions
$creadPrec :: ReadPrec DoubleOptions
readList :: ReadS [DoubleOptions]
$creadList :: ReadS [DoubleOptions]
readsPrec :: Int -> ReadS DoubleOptions
$creadsPrec :: Int -> ReadS DoubleOptions
Prelude.Read, Int -> DoubleOptions -> ShowS
[DoubleOptions] -> ShowS
DoubleOptions -> String
(Int -> DoubleOptions -> ShowS)
-> (DoubleOptions -> String)
-> ([DoubleOptions] -> ShowS)
-> Show DoubleOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DoubleOptions] -> ShowS
$cshowList :: [DoubleOptions] -> ShowS
show :: DoubleOptions -> String
$cshow :: DoubleOptions -> String
showsPrec :: Int -> DoubleOptions -> ShowS
$cshowsPrec :: Int -> DoubleOptions -> ShowS
Prelude.Show, (forall x. DoubleOptions -> Rep DoubleOptions x)
-> (forall x. Rep DoubleOptions x -> DoubleOptions)
-> Generic DoubleOptions
forall x. Rep DoubleOptions x -> DoubleOptions
forall x. DoubleOptions -> Rep DoubleOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DoubleOptions x -> DoubleOptions
$cfrom :: forall x. DoubleOptions -> Rep DoubleOptions x
Prelude.Generic)

-- |
-- Create a value of 'DoubleOptions' 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:
--
-- 'sourceField', 'doubleOptions_sourceField' - The name of the source field to map to the field.
--
-- 'returnEnabled', 'doubleOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'facetEnabled', 'doubleOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'searchEnabled', 'doubleOptions_searchEnabled' - Whether the contents of the field are searchable.
--
-- 'sortEnabled', 'doubleOptions_sortEnabled' - Whether the field can be used to sort the search results.
--
-- 'defaultValue', 'doubleOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document. This can be important if you are using the field in an
-- expression and that field is not present in every document.
newDoubleOptions ::
  DoubleOptions
newDoubleOptions :: DoubleOptions
newDoubleOptions =
  DoubleOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Double
-> DoubleOptions
DoubleOptions'
    { $sel:sourceField:DoubleOptions' :: Maybe Text
sourceField = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:DoubleOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:DoubleOptions' :: Maybe Bool
facetEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:DoubleOptions' :: Maybe Bool
searchEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:DoubleOptions' :: Maybe Bool
sortEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:DoubleOptions' :: Maybe Double
defaultValue = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the source field to map to the field.
doubleOptions_sourceField :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Text)
doubleOptions_sourceField :: (Maybe Text -> f (Maybe Text)) -> DoubleOptions -> f DoubleOptions
doubleOptions_sourceField = (DoubleOptions -> Maybe Text)
-> (DoubleOptions -> Maybe Text -> DoubleOptions)
-> Lens DoubleOptions DoubleOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleOptions' {Maybe Text
sourceField :: Maybe Text
$sel:sourceField:DoubleOptions' :: DoubleOptions -> Maybe Text
sourceField} -> Maybe Text
sourceField) (\s :: DoubleOptions
s@DoubleOptions' {} Maybe Text
a -> DoubleOptions
s {$sel:sourceField:DoubleOptions' :: Maybe Text
sourceField = Maybe Text
a} :: DoubleOptions)

-- | Whether the contents of the field can be returned in the search results.
doubleOptions_returnEnabled :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Bool)
doubleOptions_returnEnabled :: (Maybe Bool -> f (Maybe Bool)) -> DoubleOptions -> f DoubleOptions
doubleOptions_returnEnabled = (DoubleOptions -> Maybe Bool)
-> (DoubleOptions -> Maybe Bool -> DoubleOptions)
-> Lens DoubleOptions DoubleOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleOptions' {Maybe Bool
returnEnabled :: Maybe Bool
$sel:returnEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
returnEnabled} -> Maybe Bool
returnEnabled) (\s :: DoubleOptions
s@DoubleOptions' {} Maybe Bool
a -> DoubleOptions
s {$sel:returnEnabled:DoubleOptions' :: Maybe Bool
returnEnabled = Maybe Bool
a} :: DoubleOptions)

-- | Whether facet information can be returned for the field.
doubleOptions_facetEnabled :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Bool)
doubleOptions_facetEnabled :: (Maybe Bool -> f (Maybe Bool)) -> DoubleOptions -> f DoubleOptions
doubleOptions_facetEnabled = (DoubleOptions -> Maybe Bool)
-> (DoubleOptions -> Maybe Bool -> DoubleOptions)
-> Lens DoubleOptions DoubleOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleOptions' {Maybe Bool
facetEnabled :: Maybe Bool
$sel:facetEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
facetEnabled} -> Maybe Bool
facetEnabled) (\s :: DoubleOptions
s@DoubleOptions' {} Maybe Bool
a -> DoubleOptions
s {$sel:facetEnabled:DoubleOptions' :: Maybe Bool
facetEnabled = Maybe Bool
a} :: DoubleOptions)

-- | Whether the contents of the field are searchable.
doubleOptions_searchEnabled :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Bool)
doubleOptions_searchEnabled :: (Maybe Bool -> f (Maybe Bool)) -> DoubleOptions -> f DoubleOptions
doubleOptions_searchEnabled = (DoubleOptions -> Maybe Bool)
-> (DoubleOptions -> Maybe Bool -> DoubleOptions)
-> Lens DoubleOptions DoubleOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleOptions' {Maybe Bool
searchEnabled :: Maybe Bool
$sel:searchEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
searchEnabled} -> Maybe Bool
searchEnabled) (\s :: DoubleOptions
s@DoubleOptions' {} Maybe Bool
a -> DoubleOptions
s {$sel:searchEnabled:DoubleOptions' :: Maybe Bool
searchEnabled = Maybe Bool
a} :: DoubleOptions)

-- | Whether the field can be used to sort the search results.
doubleOptions_sortEnabled :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Bool)
doubleOptions_sortEnabled :: (Maybe Bool -> f (Maybe Bool)) -> DoubleOptions -> f DoubleOptions
doubleOptions_sortEnabled = (DoubleOptions -> Maybe Bool)
-> (DoubleOptions -> Maybe Bool -> DoubleOptions)
-> Lens DoubleOptions DoubleOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleOptions' {Maybe Bool
sortEnabled :: Maybe Bool
$sel:sortEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
sortEnabled} -> Maybe Bool
sortEnabled) (\s :: DoubleOptions
s@DoubleOptions' {} Maybe Bool
a -> DoubleOptions
s {$sel:sortEnabled:DoubleOptions' :: Maybe Bool
sortEnabled = Maybe Bool
a} :: DoubleOptions)

-- | A value to use for the field if the field isn\'t specified for a
-- document. This can be important if you are using the field in an
-- expression and that field is not present in every document.
doubleOptions_defaultValue :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Double)
doubleOptions_defaultValue :: (Maybe Double -> f (Maybe Double))
-> DoubleOptions -> f DoubleOptions
doubleOptions_defaultValue = (DoubleOptions -> Maybe Double)
-> (DoubleOptions -> Maybe Double -> DoubleOptions)
-> Lens DoubleOptions DoubleOptions (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleOptions' {Maybe Double
defaultValue :: Maybe Double
$sel:defaultValue:DoubleOptions' :: DoubleOptions -> Maybe Double
defaultValue} -> Maybe Double
defaultValue) (\s :: DoubleOptions
s@DoubleOptions' {} Maybe Double
a -> DoubleOptions
s {$sel:defaultValue:DoubleOptions' :: Maybe Double
defaultValue = Maybe Double
a} :: DoubleOptions)

instance Core.FromXML DoubleOptions where
  parseXML :: [Node] -> Either String DoubleOptions
parseXML [Node]
x =
    Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Double
-> DoubleOptions
DoubleOptions'
      (Maybe Text
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Double
 -> DoubleOptions)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Double
      -> DoubleOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourceField")
      Either
  String
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Double
   -> DoubleOptions)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Bool
      -> Maybe Bool -> Maybe Bool -> Maybe Double -> DoubleOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ReturnEnabled")
      Either
  String
  (Maybe Bool
   -> Maybe Bool -> Maybe Bool -> Maybe Double -> DoubleOptions)
-> Either String (Maybe Bool)
-> Either
     String (Maybe Bool -> Maybe Bool -> Maybe Double -> DoubleOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"FacetEnabled")
      Either
  String (Maybe Bool -> Maybe Bool -> Maybe Double -> DoubleOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Bool -> Maybe Double -> DoubleOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SearchEnabled")
      Either String (Maybe Bool -> Maybe Double -> DoubleOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Double -> DoubleOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SortEnabled")
      Either String (Maybe Double -> DoubleOptions)
-> Either String (Maybe Double) -> Either String DoubleOptions
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
"DefaultValue")

instance Prelude.Hashable DoubleOptions

instance Prelude.NFData DoubleOptions

instance Core.ToQuery DoubleOptions where
  toQuery :: DoubleOptions -> QueryString
toQuery DoubleOptions' {Maybe Bool
Maybe Double
Maybe Text
defaultValue :: Maybe Double
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
sourceField :: Maybe Text
$sel:defaultValue:DoubleOptions' :: DoubleOptions -> Maybe Double
$sel:sortEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:searchEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:facetEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:returnEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:sourceField:DoubleOptions' :: DoubleOptions -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SourceField" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
sourceField,
        ByteString
"ReturnEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
returnEnabled,
        ByteString
"FacetEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
facetEnabled,
        ByteString
"SearchEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
searchEnabled,
        ByteString
"SortEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
sortEnabled,
        ByteString
"DefaultValue" ByteString -> Maybe Double -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Double
defaultValue
      ]