{-# 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.ColumnMetadata
-- 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.ColumnMetadata 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

-- | Metadata for column in the table.
--
-- /See:/ 'newColumnMetadata' smart constructor.
data ColumnMetadata = ColumnMetadata'
  { -- | The name of the column.
    ColumnMetadata -> Sensitive Text
name :: Data.Sensitive Prelude.Text,
    -- | The format of the column.
    ColumnMetadata -> Format
format :: Format
  }
  deriving (ColumnMetadata -> ColumnMetadata -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnMetadata -> ColumnMetadata -> Bool
$c/= :: ColumnMetadata -> ColumnMetadata -> Bool
== :: ColumnMetadata -> ColumnMetadata -> Bool
$c== :: ColumnMetadata -> ColumnMetadata -> Bool
Prelude.Eq, Int -> ColumnMetadata -> ShowS
[ColumnMetadata] -> ShowS
ColumnMetadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnMetadata] -> ShowS
$cshowList :: [ColumnMetadata] -> ShowS
show :: ColumnMetadata -> String
$cshow :: ColumnMetadata -> String
showsPrec :: Int -> ColumnMetadata -> ShowS
$cshowsPrec :: Int -> ColumnMetadata -> ShowS
Prelude.Show, forall x. Rep ColumnMetadata x -> ColumnMetadata
forall x. ColumnMetadata -> Rep ColumnMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnMetadata x -> ColumnMetadata
$cfrom :: forall x. ColumnMetadata -> Rep ColumnMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ColumnMetadata' 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:
--
-- 'name', 'columnMetadata_name' - The name of the column.
--
-- 'format', 'columnMetadata_format' - The format of the column.
newColumnMetadata ::
  -- | 'name'
  Prelude.Text ->
  -- | 'format'
  Format ->
  ColumnMetadata
newColumnMetadata :: Text -> Format -> ColumnMetadata
newColumnMetadata Text
pName_ Format
pFormat_ =
  ColumnMetadata'
    { $sel:name:ColumnMetadata' :: Sensitive Text
name =
        forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pName_,
      $sel:format:ColumnMetadata' :: Format
format = Format
pFormat_
    }

-- | The name of the column.
columnMetadata_name :: Lens.Lens' ColumnMetadata Prelude.Text
columnMetadata_name :: Lens' ColumnMetadata Text
columnMetadata_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnMetadata' {Sensitive Text
name :: Sensitive Text
$sel:name:ColumnMetadata' :: ColumnMetadata -> Sensitive Text
name} -> Sensitive Text
name) (\s :: ColumnMetadata
s@ColumnMetadata' {} Sensitive Text
a -> ColumnMetadata
s {$sel:name:ColumnMetadata' :: Sensitive Text
name = Sensitive Text
a} :: ColumnMetadata) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The format of the column.
columnMetadata_format :: Lens.Lens' ColumnMetadata Format
columnMetadata_format :: Lens' ColumnMetadata Format
columnMetadata_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnMetadata' {Format
format :: Format
$sel:format:ColumnMetadata' :: ColumnMetadata -> Format
format} -> Format
format) (\s :: ColumnMetadata
s@ColumnMetadata' {} Format
a -> ColumnMetadata
s {$sel:format:ColumnMetadata' :: Format
format = Format
a} :: ColumnMetadata)

instance Data.FromJSON ColumnMetadata where
  parseJSON :: Value -> Parser ColumnMetadata
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnMetadata"
      ( \Object
x ->
          Sensitive Text -> Format -> ColumnMetadata
ColumnMetadata'
            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
"name")
            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
"format")
      )

instance Prelude.Hashable ColumnMetadata where
  hashWithSalt :: Int -> ColumnMetadata -> Int
hashWithSalt Int
_salt ColumnMetadata' {Sensitive Text
Format
format :: Format
name :: Sensitive Text
$sel:format:ColumnMetadata' :: ColumnMetadata -> Format
$sel:name:ColumnMetadata' :: ColumnMetadata -> Sensitive Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Format
format

instance Prelude.NFData ColumnMetadata where
  rnf :: ColumnMetadata -> ()
rnf ColumnMetadata' {Sensitive Text
Format
format :: Format
name :: Sensitive Text
$sel:format:ColumnMetadata' :: ColumnMetadata -> Format
$sel:name:ColumnMetadata' :: ColumnMetadata -> Sensitive Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Format
format