{-# 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.SageMakerFeatureStoreRuntime.Types.FeatureValue
-- 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.SageMakerFeatureStoreRuntime.Types.FeatureValue 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

-- | The value associated with a feature.
--
-- /See:/ 'newFeatureValue' smart constructor.
data FeatureValue = FeatureValue'
  { -- | The name of a feature that a feature value corresponds to.
    FeatureValue -> Text
featureName :: Prelude.Text,
    -- | The value associated with a feature, in string format. Note that
    -- features types can be String, Integral, or Fractional. This value
    -- represents all three types as a string.
    FeatureValue -> Text
valueAsString :: Prelude.Text
  }
  deriving (FeatureValue -> FeatureValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FeatureValue -> FeatureValue -> Bool
$c/= :: FeatureValue -> FeatureValue -> Bool
== :: FeatureValue -> FeatureValue -> Bool
$c== :: FeatureValue -> FeatureValue -> Bool
Prelude.Eq, ReadPrec [FeatureValue]
ReadPrec FeatureValue
Int -> ReadS FeatureValue
ReadS [FeatureValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FeatureValue]
$creadListPrec :: ReadPrec [FeatureValue]
readPrec :: ReadPrec FeatureValue
$creadPrec :: ReadPrec FeatureValue
readList :: ReadS [FeatureValue]
$creadList :: ReadS [FeatureValue]
readsPrec :: Int -> ReadS FeatureValue
$creadsPrec :: Int -> ReadS FeatureValue
Prelude.Read, Int -> FeatureValue -> ShowS
[FeatureValue] -> ShowS
FeatureValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FeatureValue] -> ShowS
$cshowList :: [FeatureValue] -> ShowS
show :: FeatureValue -> String
$cshow :: FeatureValue -> String
showsPrec :: Int -> FeatureValue -> ShowS
$cshowsPrec :: Int -> FeatureValue -> ShowS
Prelude.Show, forall x. Rep FeatureValue x -> FeatureValue
forall x. FeatureValue -> Rep FeatureValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FeatureValue x -> FeatureValue
$cfrom :: forall x. FeatureValue -> Rep FeatureValue x
Prelude.Generic)

-- |
-- Create a value of 'FeatureValue' 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:
--
-- 'featureName', 'featureValue_featureName' - The name of a feature that a feature value corresponds to.
--
-- 'valueAsString', 'featureValue_valueAsString' - The value associated with a feature, in string format. Note that
-- features types can be String, Integral, or Fractional. This value
-- represents all three types as a string.
newFeatureValue ::
  -- | 'featureName'
  Prelude.Text ->
  -- | 'valueAsString'
  Prelude.Text ->
  FeatureValue
newFeatureValue :: Text -> Text -> FeatureValue
newFeatureValue Text
pFeatureName_ Text
pValueAsString_ =
  FeatureValue'
    { $sel:featureName:FeatureValue' :: Text
featureName = Text
pFeatureName_,
      $sel:valueAsString:FeatureValue' :: Text
valueAsString = Text
pValueAsString_
    }

-- | The name of a feature that a feature value corresponds to.
featureValue_featureName :: Lens.Lens' FeatureValue Prelude.Text
featureValue_featureName :: Lens' FeatureValue Text
featureValue_featureName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FeatureValue' {Text
featureName :: Text
$sel:featureName:FeatureValue' :: FeatureValue -> Text
featureName} -> Text
featureName) (\s :: FeatureValue
s@FeatureValue' {} Text
a -> FeatureValue
s {$sel:featureName:FeatureValue' :: Text
featureName = Text
a} :: FeatureValue)

-- | The value associated with a feature, in string format. Note that
-- features types can be String, Integral, or Fractional. This value
-- represents all three types as a string.
featureValue_valueAsString :: Lens.Lens' FeatureValue Prelude.Text
featureValue_valueAsString :: Lens' FeatureValue Text
featureValue_valueAsString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FeatureValue' {Text
valueAsString :: Text
$sel:valueAsString:FeatureValue' :: FeatureValue -> Text
valueAsString} -> Text
valueAsString) (\s :: FeatureValue
s@FeatureValue' {} Text
a -> FeatureValue
s {$sel:valueAsString:FeatureValue' :: Text
valueAsString = Text
a} :: FeatureValue)

instance Data.FromJSON FeatureValue where
  parseJSON :: Value -> Parser FeatureValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FeatureValue"
      ( \Object
x ->
          Text -> Text -> FeatureValue
FeatureValue'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FeatureName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ValueAsString")
      )

instance Prelude.Hashable FeatureValue where
  hashWithSalt :: Int -> FeatureValue -> Int
hashWithSalt Int
_salt FeatureValue' {Text
valueAsString :: Text
featureName :: Text
$sel:valueAsString:FeatureValue' :: FeatureValue -> Text
$sel:featureName:FeatureValue' :: FeatureValue -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
featureName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
valueAsString

instance Prelude.NFData FeatureValue where
  rnf :: FeatureValue -> ()
rnf FeatureValue' {Text
valueAsString :: Text
featureName :: Text
$sel:valueAsString:FeatureValue' :: FeatureValue -> Text
$sel:featureName:FeatureValue' :: FeatureValue -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
featureName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
valueAsString

instance Data.ToJSON FeatureValue where
  toJSON :: FeatureValue -> Value
toJSON FeatureValue' {Text
valueAsString :: Text
featureName :: Text
$sel:valueAsString:FeatureValue' :: FeatureValue -> Text
$sel:featureName:FeatureValue' :: FeatureValue -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"FeatureName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
featureName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ValueAsString" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
valueAsString)
          ]
      )