{-# 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.KeySpaces.Types.Comment
-- 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.KeySpaces.Types.Comment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An optional comment that describes the table.
--
-- /See:/ 'newComment' smart constructor.
data Comment = Comment'
  { -- | An optional description of the table.
    Comment -> Text
message :: Prelude.Text
  }
  deriving (Comment -> Comment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Comment -> Comment -> Bool
$c/= :: Comment -> Comment -> Bool
== :: Comment -> Comment -> Bool
$c== :: Comment -> Comment -> Bool
Prelude.Eq, ReadPrec [Comment]
ReadPrec Comment
Int -> ReadS Comment
ReadS [Comment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Comment]
$creadListPrec :: ReadPrec [Comment]
readPrec :: ReadPrec Comment
$creadPrec :: ReadPrec Comment
readList :: ReadS [Comment]
$creadList :: ReadS [Comment]
readsPrec :: Int -> ReadS Comment
$creadsPrec :: Int -> ReadS Comment
Prelude.Read, Int -> Comment -> ShowS
[Comment] -> ShowS
Comment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Comment] -> ShowS
$cshowList :: [Comment] -> ShowS
show :: Comment -> String
$cshow :: Comment -> String
showsPrec :: Int -> Comment -> ShowS
$cshowsPrec :: Int -> Comment -> ShowS
Prelude.Show, forall x. Rep Comment x -> Comment
forall x. Comment -> Rep Comment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Comment x -> Comment
$cfrom :: forall x. Comment -> Rep Comment x
Prelude.Generic)

-- |
-- Create a value of 'Comment' 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:
--
-- 'message', 'comment_message' - An optional description of the table.
newComment ::
  -- | 'message'
  Prelude.Text ->
  Comment
newComment :: Text -> Comment
newComment Text
pMessage_ = Comment' {$sel:message:Comment' :: Text
message = Text
pMessage_}

-- | An optional description of the table.
comment_message :: Lens.Lens' Comment Prelude.Text
comment_message :: Lens' Comment Text
comment_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Text
message :: Text
$sel:message:Comment' :: Comment -> Text
message} -> Text
message) (\s :: Comment
s@Comment' {} Text
a -> Comment
s {$sel:message:Comment' :: Text
message = Text
a} :: Comment)

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

instance Prelude.Hashable Comment where
  hashWithSalt :: Int -> Comment -> Int
hashWithSalt Int
_salt Comment' {Text
message :: Text
$sel:message:Comment' :: Comment -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
message

instance Prelude.NFData Comment where
  rnf :: Comment -> ()
rnf Comment' {Text
message :: Text
$sel:message:Comment' :: Comment -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
message

instance Data.ToJSON Comment where
  toJSON :: Comment -> Value
toJSON Comment' {Text
message :: Text
$sel:message:Comment' :: Comment -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"message" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
message)]
      )