{-# 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.IotTwinMaker.Types.ColumnDescription
-- 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.IotTwinMaker.Types.ColumnDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types.ColumnType
import qualified Amazonka.Prelude as Prelude

-- | A description of the column in the query results.
--
-- /See:/ 'newColumnDescription' smart constructor.
data ColumnDescription = ColumnDescription'
  { -- | The name of the column description.
    ColumnDescription -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The type of the column description.
    ColumnDescription -> Maybe ColumnType
type' :: Prelude.Maybe ColumnType
  }
  deriving (ColumnDescription -> ColumnDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnDescription -> ColumnDescription -> Bool
$c/= :: ColumnDescription -> ColumnDescription -> Bool
== :: ColumnDescription -> ColumnDescription -> Bool
$c== :: ColumnDescription -> ColumnDescription -> Bool
Prelude.Eq, ReadPrec [ColumnDescription]
ReadPrec ColumnDescription
Int -> ReadS ColumnDescription
ReadS [ColumnDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnDescription]
$creadListPrec :: ReadPrec [ColumnDescription]
readPrec :: ReadPrec ColumnDescription
$creadPrec :: ReadPrec ColumnDescription
readList :: ReadS [ColumnDescription]
$creadList :: ReadS [ColumnDescription]
readsPrec :: Int -> ReadS ColumnDescription
$creadsPrec :: Int -> ReadS ColumnDescription
Prelude.Read, Int -> ColumnDescription -> ShowS
[ColumnDescription] -> ShowS
ColumnDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnDescription] -> ShowS
$cshowList :: [ColumnDescription] -> ShowS
show :: ColumnDescription -> String
$cshow :: ColumnDescription -> String
showsPrec :: Int -> ColumnDescription -> ShowS
$cshowsPrec :: Int -> ColumnDescription -> ShowS
Prelude.Show, forall x. Rep ColumnDescription x -> ColumnDescription
forall x. ColumnDescription -> Rep ColumnDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnDescription x -> ColumnDescription
$cfrom :: forall x. ColumnDescription -> Rep ColumnDescription x
Prelude.Generic)

-- |
-- Create a value of 'ColumnDescription' 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', 'columnDescription_name' - The name of the column description.
--
-- 'type'', 'columnDescription_type' - The type of the column description.
newColumnDescription ::
  ColumnDescription
newColumnDescription :: ColumnDescription
newColumnDescription =
  ColumnDescription'
    { $sel:name:ColumnDescription' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ColumnDescription' :: Maybe ColumnType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the column description.
columnDescription_name :: Lens.Lens' ColumnDescription (Prelude.Maybe Prelude.Text)
columnDescription_name :: Lens' ColumnDescription (Maybe Text)
columnDescription_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnDescription' {Maybe Text
name :: Maybe Text
$sel:name:ColumnDescription' :: ColumnDescription -> Maybe Text
name} -> Maybe Text
name) (\s :: ColumnDescription
s@ColumnDescription' {} Maybe Text
a -> ColumnDescription
s {$sel:name:ColumnDescription' :: Maybe Text
name = Maybe Text
a} :: ColumnDescription)

-- | The type of the column description.
columnDescription_type :: Lens.Lens' ColumnDescription (Prelude.Maybe ColumnType)
columnDescription_type :: Lens' ColumnDescription (Maybe ColumnType)
columnDescription_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnDescription' {Maybe ColumnType
type' :: Maybe ColumnType
$sel:type':ColumnDescription' :: ColumnDescription -> Maybe ColumnType
type'} -> Maybe ColumnType
type') (\s :: ColumnDescription
s@ColumnDescription' {} Maybe ColumnType
a -> ColumnDescription
s {$sel:type':ColumnDescription' :: Maybe ColumnType
type' = Maybe ColumnType
a} :: ColumnDescription)

instance Data.FromJSON ColumnDescription where
  parseJSON :: Value -> Parser ColumnDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnDescription"
      ( \Object
x ->
          Maybe Text -> Maybe ColumnType -> ColumnDescription
ColumnDescription'
            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
"name")
            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
"type")
      )

instance Prelude.Hashable ColumnDescription where
  hashWithSalt :: Int -> ColumnDescription -> Int
hashWithSalt Int
_salt ColumnDescription' {Maybe Text
Maybe ColumnType
type' :: Maybe ColumnType
name :: Maybe Text
$sel:type':ColumnDescription' :: ColumnDescription -> Maybe ColumnType
$sel:name:ColumnDescription' :: ColumnDescription -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ColumnType
type'

instance Prelude.NFData ColumnDescription where
  rnf :: ColumnDescription -> ()
rnf ColumnDescription' {Maybe Text
Maybe ColumnType
type' :: Maybe ColumnType
name :: Maybe Text
$sel:type':ColumnDescription' :: ColumnDescription -> Maybe ColumnType
$sel:name:ColumnDescription' :: ColumnDescription -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ColumnType
type'