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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.HoneyCode.Types.Format
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 formatted value of the data. e.g. John Smith.
    DataItem -> Maybe Text
formattedValue :: 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 raw value of the data. e.g. jsmith\@example.com
    DataItem -> Maybe Text
rawValue :: Prelude.Maybe Prelude.Text
  }
  deriving (DataItem -> DataItem -> Bool
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
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. 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:
--
-- 'formattedValue', 'dataItem_formattedValue' - The formatted value of the data. e.g. John Smith.
--
-- '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.
--
-- 'rawValue', 'dataItem_rawValue' - The raw value of the data. e.g. jsmith\@example.com
newDataItem ::
  DataItem
newDataItem :: DataItem
newDataItem =
  DataItem'
    { $sel:formattedValue:DataItem' :: Maybe Text
formattedValue = forall a. Maybe a
Prelude.Nothing,
      $sel:overrideFormat:DataItem' :: Maybe Format
overrideFormat = forall a. Maybe a
Prelude.Nothing,
      $sel:rawValue:DataItem' :: Maybe Text
rawValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The formatted value of the data. e.g. John Smith.
dataItem_formattedValue :: Lens.Lens' DataItem (Prelude.Maybe Prelude.Text)
dataItem_formattedValue :: Lens' DataItem (Maybe Text)
dataItem_formattedValue = 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)

-- | 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 :: Lens' DataItem (Maybe Format)
dataItem_overrideFormat = 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 raw value of the data. e.g. jsmith\@example.com
dataItem_rawValue :: Lens.Lens' DataItem (Prelude.Maybe Prelude.Text)
dataItem_rawValue :: Lens' DataItem (Maybe Text)
dataItem_rawValue = 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)

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

instance Prelude.Hashable DataItem where
  hashWithSalt :: Int -> DataItem -> Int
hashWithSalt Int
_salt DataItem' {Maybe Text
Maybe Format
rawValue :: Maybe Text
overrideFormat :: Maybe Format
formattedValue :: Maybe Text
$sel:rawValue:DataItem' :: DataItem -> Maybe Text
$sel:overrideFormat:DataItem' :: DataItem -> Maybe Format
$sel:formattedValue:DataItem' :: DataItem -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
formattedValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Format
overrideFormat
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rawValue

instance Prelude.NFData DataItem where
  rnf :: DataItem -> ()
rnf DataItem' {Maybe Text
Maybe Format
rawValue :: Maybe Text
overrideFormat :: Maybe Format
formattedValue :: Maybe Text
$sel:rawValue:DataItem' :: DataItem -> Maybe Text
$sel:overrideFormat:DataItem' :: DataItem -> Maybe Format
$sel:formattedValue:DataItem' :: DataItem -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
formattedValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Format
overrideFormat
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rawValue