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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(FeatureValue -> FeatureValue -> Bool)
-> (FeatureValue -> FeatureValue -> Bool) -> Eq FeatureValue
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]
(Int -> ReadS FeatureValue)
-> ReadS [FeatureValue]
-> ReadPrec FeatureValue
-> ReadPrec [FeatureValue]
-> Read 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
(Int -> FeatureValue -> ShowS)
-> (FeatureValue -> String)
-> ([FeatureValue] -> ShowS)
-> Show FeatureValue
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. FeatureValue -> Rep FeatureValue x)
-> (forall x. Rep FeatureValue x -> FeatureValue)
-> Generic FeatureValue
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' :: Text -> Text -> FeatureValue
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 :: (Text -> f Text) -> FeatureValue -> f FeatureValue
featureValue_featureName = (FeatureValue -> Text)
-> (FeatureValue -> Text -> FeatureValue)
-> Lens FeatureValue FeatureValue Text Text
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 :: (Text -> f Text) -> FeatureValue -> f FeatureValue
featureValue_valueAsString = (FeatureValue -> Text)
-> (FeatureValue -> Text -> FeatureValue)
-> Lens FeatureValue FeatureValue Text Text
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 Core.FromJSON FeatureValue where
  parseJSON :: Value -> Parser FeatureValue
parseJSON =
    String
-> (Object -> Parser FeatureValue) -> Value -> Parser FeatureValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FeatureValue"
      ( \Object
x ->
          Text -> Text -> FeatureValue
FeatureValue'
            (Text -> Text -> FeatureValue)
-> Parser Text -> Parser (Text -> FeatureValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FeatureName")
            Parser (Text -> FeatureValue) -> Parser Text -> Parser FeatureValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ValueAsString")
      )

instance Prelude.Hashable FeatureValue

instance Prelude.NFData FeatureValue

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FeatureName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
featureName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ValueAsString" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
valueAsString)
          ]
      )