{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudSearch.Types.DoubleOptions 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

-- | 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'
  { -- | 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,
    -- | Whether facet information can be returned for the field.
    DoubleOptions -> Maybe Bool
facetEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the contents of the field can be returned in the search results.
    DoubleOptions -> Maybe Bool
returnEnabled :: 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,
    -- | The name of the source field to map to the field.
    DoubleOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text
  }
  deriving (DoubleOptions -> DoubleOptions -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'facetEnabled', 'doubleOptions_facetEnabled' - Whether facet information can be returned for the field.
--
-- 'returnEnabled', 'doubleOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- '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.
--
-- 'sourceField', 'doubleOptions_sourceField' - The name of the source field to map to the field.
newDoubleOptions ::
  DoubleOptions
newDoubleOptions :: DoubleOptions
newDoubleOptions =
  DoubleOptions'
    { $sel:defaultValue:DoubleOptions' :: Maybe Double
defaultValue = forall a. Maybe a
Prelude.Nothing,
      $sel:facetEnabled:DoubleOptions' :: Maybe Bool
facetEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:DoubleOptions' :: Maybe Bool
returnEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:searchEnabled:DoubleOptions' :: Maybe Bool
searchEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:DoubleOptions' :: Maybe Bool
sortEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceField:DoubleOptions' :: Maybe Text
sourceField = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' DoubleOptions (Maybe Double)
doubleOptions_defaultValue = 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)

-- | Whether facet information can be returned for the field.
doubleOptions_facetEnabled :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Bool)
doubleOptions_facetEnabled :: Lens' DoubleOptions (Maybe Bool)
doubleOptions_facetEnabled = 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 can be returned in the search results.
doubleOptions_returnEnabled :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Bool)
doubleOptions_returnEnabled :: Lens' DoubleOptions (Maybe Bool)
doubleOptions_returnEnabled = 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 the contents of the field are searchable.
doubleOptions_searchEnabled :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Bool)
doubleOptions_searchEnabled :: Lens' DoubleOptions (Maybe Bool)
doubleOptions_searchEnabled = 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 :: Lens' DoubleOptions (Maybe Bool)
doubleOptions_sortEnabled = 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)

-- | The name of the source field to map to the field.
doubleOptions_sourceField :: Lens.Lens' DoubleOptions (Prelude.Maybe Prelude.Text)
doubleOptions_sourceField :: Lens' DoubleOptions (Maybe Text)
doubleOptions_sourceField = 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)

instance Data.FromXML DoubleOptions where
  parseXML :: [Node] -> Either String DoubleOptions
parseXML [Node]
x =
    Maybe Double
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> DoubleOptions
DoubleOptions'
      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
"DefaultValue")
      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
"FacetEnabled")
      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
"ReturnEnabled")
      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
"SearchEnabled")
      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
"SortEnabled")
      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
"SourceField")

instance Prelude.Hashable DoubleOptions where
  hashWithSalt :: Int -> DoubleOptions -> Int
hashWithSalt Int
_salt DoubleOptions' {Maybe Bool
Maybe Double
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Double
$sel:sourceField:DoubleOptions' :: DoubleOptions -> Maybe Text
$sel:sortEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:searchEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:returnEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:facetEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:defaultValue:DoubleOptions' :: DoubleOptions -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
defaultValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
facetEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
returnEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
searchEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
sortEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceField

instance Prelude.NFData DoubleOptions where
  rnf :: DoubleOptions -> ()
rnf DoubleOptions' {Maybe Bool
Maybe Double
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
searchEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
facetEnabled :: Maybe Bool
defaultValue :: Maybe Double
$sel:sourceField:DoubleOptions' :: DoubleOptions -> Maybe Text
$sel:sortEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:searchEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:returnEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:facetEnabled:DoubleOptions' :: DoubleOptions -> Maybe Bool
$sel:defaultValue:DoubleOptions' :: DoubleOptions -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
defaultValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
facetEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
returnEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
searchEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
sortEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceField

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