{-# 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.HoneyCode.Types.DataItem
-- 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.HoneyCode.Types.DataItem where

import qualified Amazonka.Core as Core
import Amazonka.HoneyCode.Types.Format
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The data in a particular data cell defined on the screen.
--
-- /See:/ 'newDataItem' smart constructor.
data DataItem = DataItem'
  { -- | The raw value of the data. e.g. jsmith\@example.com
    DataItem -> Maybe Text
rawValue :: Prelude.Maybe Prelude.Text,
    -- | The overrideFormat is optional and is specified only if a particular row
    -- of data has a different format for the data than the default format
    -- defined on the screen or the table.
    DataItem -> Maybe Format
overrideFormat :: Prelude.Maybe Format,
    -- | The formatted value of the data. e.g. John Smith.
    DataItem -> Maybe Text
formattedValue :: Prelude.Maybe Prelude.Text
  }
  deriving (DataItem -> DataItem -> Bool
(DataItem -> DataItem -> Bool)
-> (DataItem -> DataItem -> Bool) -> Eq DataItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataItem -> DataItem -> Bool
$c/= :: DataItem -> DataItem -> Bool
== :: DataItem -> DataItem -> Bool
$c== :: DataItem -> DataItem -> Bool
Prelude.Eq, Int -> DataItem -> ShowS
[DataItem] -> ShowS
DataItem -> String
(Int -> DataItem -> ShowS)
-> (DataItem -> String) -> ([DataItem] -> ShowS) -> Show DataItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataItem] -> ShowS
$cshowList :: [DataItem] -> ShowS
show :: DataItem -> String
$cshow :: DataItem -> String
showsPrec :: Int -> DataItem -> ShowS
$cshowsPrec :: Int -> DataItem -> ShowS
Prelude.Show, (forall x. DataItem -> Rep DataItem x)
-> (forall x. Rep DataItem x -> DataItem) -> Generic DataItem
forall x. Rep DataItem x -> DataItem
forall x. DataItem -> Rep DataItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataItem x -> DataItem
$cfrom :: forall x. DataItem -> Rep DataItem x
Prelude.Generic)

-- |
-- Create a value of 'DataItem' 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:
--
-- 'rawValue', 'dataItem_rawValue' - The raw value of the data. e.g. jsmith\@example.com
--
-- 'overrideFormat', 'dataItem_overrideFormat' - The overrideFormat is optional and is specified only if a particular row
-- of data has a different format for the data than the default format
-- defined on the screen or the table.
--
-- 'formattedValue', 'dataItem_formattedValue' - The formatted value of the data. e.g. John Smith.
newDataItem ::
  DataItem
newDataItem :: DataItem
newDataItem =
  DataItem' :: Maybe Text -> Maybe Format -> Maybe Text -> DataItem
DataItem'
    { $sel:rawValue:DataItem' :: Maybe Text
rawValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:overrideFormat:DataItem' :: Maybe Format
overrideFormat = Maybe Format
forall a. Maybe a
Prelude.Nothing,
      $sel:formattedValue:DataItem' :: Maybe Text
formattedValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The raw value of the data. e.g. jsmith\@example.com
dataItem_rawValue :: Lens.Lens' DataItem (Prelude.Maybe Prelude.Text)
dataItem_rawValue :: (Maybe Text -> f (Maybe Text)) -> DataItem -> f DataItem
dataItem_rawValue = (DataItem -> Maybe Text)
-> (DataItem -> Maybe Text -> DataItem)
-> Lens DataItem DataItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataItem' {Maybe Text
rawValue :: Maybe Text
$sel:rawValue:DataItem' :: DataItem -> Maybe Text
rawValue} -> Maybe Text
rawValue) (\s :: DataItem
s@DataItem' {} Maybe Text
a -> DataItem
s {$sel:rawValue:DataItem' :: Maybe Text
rawValue = Maybe Text
a} :: DataItem)

-- | The overrideFormat is optional and is specified only if a particular row
-- of data has a different format for the data than the default format
-- defined on the screen or the table.
dataItem_overrideFormat :: Lens.Lens' DataItem (Prelude.Maybe Format)
dataItem_overrideFormat :: (Maybe Format -> f (Maybe Format)) -> DataItem -> f DataItem
dataItem_overrideFormat = (DataItem -> Maybe Format)
-> (DataItem -> Maybe Format -> DataItem)
-> Lens DataItem DataItem (Maybe Format) (Maybe Format)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataItem' {Maybe Format
overrideFormat :: Maybe Format
$sel:overrideFormat:DataItem' :: DataItem -> Maybe Format
overrideFormat} -> Maybe Format
overrideFormat) (\s :: DataItem
s@DataItem' {} Maybe Format
a -> DataItem
s {$sel:overrideFormat:DataItem' :: Maybe Format
overrideFormat = Maybe Format
a} :: DataItem)

-- | The formatted value of the data. e.g. John Smith.
dataItem_formattedValue :: Lens.Lens' DataItem (Prelude.Maybe Prelude.Text)
dataItem_formattedValue :: (Maybe Text -> f (Maybe Text)) -> DataItem -> f DataItem
dataItem_formattedValue = (DataItem -> Maybe Text)
-> (DataItem -> Maybe Text -> DataItem)
-> Lens DataItem DataItem (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataItem' {Maybe Text
formattedValue :: Maybe Text
$sel:formattedValue:DataItem' :: DataItem -> Maybe Text
formattedValue} -> Maybe Text
formattedValue) (\s :: DataItem
s@DataItem' {} Maybe Text
a -> DataItem
s {$sel:formattedValue:DataItem' :: Maybe Text
formattedValue = Maybe Text
a} :: DataItem)

instance Core.FromJSON DataItem where
  parseJSON :: Value -> Parser DataItem
parseJSON =
    String -> (Object -> Parser DataItem) -> Value -> Parser DataItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataItem"
      ( \Object
x ->
          Maybe Text -> Maybe Format -> Maybe Text -> DataItem
DataItem'
            (Maybe Text -> Maybe Format -> Maybe Text -> DataItem)
-> Parser (Maybe Text)
-> Parser (Maybe Format -> Maybe Text -> DataItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"rawValue")
            Parser (Maybe Format -> Maybe Text -> DataItem)
-> Parser (Maybe Format) -> Parser (Maybe Text -> DataItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Format)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"overrideFormat")
            Parser (Maybe Text -> DataItem)
-> Parser (Maybe Text) -> Parser DataItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"formattedValue")
      )

instance Prelude.Hashable DataItem

instance Prelude.NFData DataItem