{-# 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.AmplifyUiBuilder.Types.ComponentBindingPropertiesValue
-- 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.AmplifyUiBuilder.Types.ComponentBindingPropertiesValue where

import Amazonka.AmplifyUiBuilder.Types.ComponentBindingPropertiesValueProperties
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

-- | Represents the data binding configuration for a component at runtime.
-- You can use @ComponentBindingPropertiesValue@ to add exposed properties
-- to a component to allow different values to be entered when a component
-- is reused in different places in an app.
--
-- /See:/ 'newComponentBindingPropertiesValue' smart constructor.
data ComponentBindingPropertiesValue = ComponentBindingPropertiesValue'
  { -- | Describes the properties to customize with data at runtime.
    ComponentBindingPropertiesValue
-> Maybe ComponentBindingPropertiesValueProperties
bindingProperties :: Prelude.Maybe ComponentBindingPropertiesValueProperties,
    -- | The default value of the property.
    ComponentBindingPropertiesValue -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text,
    -- | The property type.
    ComponentBindingPropertiesValue -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (ComponentBindingPropertiesValue
-> ComponentBindingPropertiesValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentBindingPropertiesValue
-> ComponentBindingPropertiesValue -> Bool
$c/= :: ComponentBindingPropertiesValue
-> ComponentBindingPropertiesValue -> Bool
== :: ComponentBindingPropertiesValue
-> ComponentBindingPropertiesValue -> Bool
$c== :: ComponentBindingPropertiesValue
-> ComponentBindingPropertiesValue -> Bool
Prelude.Eq, ReadPrec [ComponentBindingPropertiesValue]
ReadPrec ComponentBindingPropertiesValue
Int -> ReadS ComponentBindingPropertiesValue
ReadS [ComponentBindingPropertiesValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentBindingPropertiesValue]
$creadListPrec :: ReadPrec [ComponentBindingPropertiesValue]
readPrec :: ReadPrec ComponentBindingPropertiesValue
$creadPrec :: ReadPrec ComponentBindingPropertiesValue
readList :: ReadS [ComponentBindingPropertiesValue]
$creadList :: ReadS [ComponentBindingPropertiesValue]
readsPrec :: Int -> ReadS ComponentBindingPropertiesValue
$creadsPrec :: Int -> ReadS ComponentBindingPropertiesValue
Prelude.Read, Int -> ComponentBindingPropertiesValue -> ShowS
[ComponentBindingPropertiesValue] -> ShowS
ComponentBindingPropertiesValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentBindingPropertiesValue] -> ShowS
$cshowList :: [ComponentBindingPropertiesValue] -> ShowS
show :: ComponentBindingPropertiesValue -> String
$cshow :: ComponentBindingPropertiesValue -> String
showsPrec :: Int -> ComponentBindingPropertiesValue -> ShowS
$cshowsPrec :: Int -> ComponentBindingPropertiesValue -> ShowS
Prelude.Show, forall x.
Rep ComponentBindingPropertiesValue x
-> ComponentBindingPropertiesValue
forall x.
ComponentBindingPropertiesValue
-> Rep ComponentBindingPropertiesValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ComponentBindingPropertiesValue x
-> ComponentBindingPropertiesValue
$cfrom :: forall x.
ComponentBindingPropertiesValue
-> Rep ComponentBindingPropertiesValue x
Prelude.Generic)

-- |
-- Create a value of 'ComponentBindingPropertiesValue' 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:
--
-- 'bindingProperties', 'componentBindingPropertiesValue_bindingProperties' - Describes the properties to customize with data at runtime.
--
-- 'defaultValue', 'componentBindingPropertiesValue_defaultValue' - The default value of the property.
--
-- 'type'', 'componentBindingPropertiesValue_type' - The property type.
newComponentBindingPropertiesValue ::
  ComponentBindingPropertiesValue
newComponentBindingPropertiesValue :: ComponentBindingPropertiesValue
newComponentBindingPropertiesValue =
  ComponentBindingPropertiesValue'
    { $sel:bindingProperties:ComponentBindingPropertiesValue' :: Maybe ComponentBindingPropertiesValueProperties
bindingProperties =
        forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:ComponentBindingPropertiesValue' :: Maybe Text
defaultValue = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ComponentBindingPropertiesValue' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | Describes the properties to customize with data at runtime.
componentBindingPropertiesValue_bindingProperties :: Lens.Lens' ComponentBindingPropertiesValue (Prelude.Maybe ComponentBindingPropertiesValueProperties)
componentBindingPropertiesValue_bindingProperties :: Lens'
  ComponentBindingPropertiesValue
  (Maybe ComponentBindingPropertiesValueProperties)
componentBindingPropertiesValue_bindingProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentBindingPropertiesValue' {Maybe ComponentBindingPropertiesValueProperties
bindingProperties :: Maybe ComponentBindingPropertiesValueProperties
$sel:bindingProperties:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue
-> Maybe ComponentBindingPropertiesValueProperties
bindingProperties} -> Maybe ComponentBindingPropertiesValueProperties
bindingProperties) (\s :: ComponentBindingPropertiesValue
s@ComponentBindingPropertiesValue' {} Maybe ComponentBindingPropertiesValueProperties
a -> ComponentBindingPropertiesValue
s {$sel:bindingProperties:ComponentBindingPropertiesValue' :: Maybe ComponentBindingPropertiesValueProperties
bindingProperties = Maybe ComponentBindingPropertiesValueProperties
a} :: ComponentBindingPropertiesValue)

-- | The default value of the property.
componentBindingPropertiesValue_defaultValue :: Lens.Lens' ComponentBindingPropertiesValue (Prelude.Maybe Prelude.Text)
componentBindingPropertiesValue_defaultValue :: Lens' ComponentBindingPropertiesValue (Maybe Text)
componentBindingPropertiesValue_defaultValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentBindingPropertiesValue' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: ComponentBindingPropertiesValue
s@ComponentBindingPropertiesValue' {} Maybe Text
a -> ComponentBindingPropertiesValue
s {$sel:defaultValue:ComponentBindingPropertiesValue' :: Maybe Text
defaultValue = Maybe Text
a} :: ComponentBindingPropertiesValue)

-- | The property type.
componentBindingPropertiesValue_type :: Lens.Lens' ComponentBindingPropertiesValue (Prelude.Maybe Prelude.Text)
componentBindingPropertiesValue_type :: Lens' ComponentBindingPropertiesValue (Maybe Text)
componentBindingPropertiesValue_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentBindingPropertiesValue' {Maybe Text
type' :: Maybe Text
$sel:type':ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
type'} -> Maybe Text
type') (\s :: ComponentBindingPropertiesValue
s@ComponentBindingPropertiesValue' {} Maybe Text
a -> ComponentBindingPropertiesValue
s {$sel:type':ComponentBindingPropertiesValue' :: Maybe Text
type' = Maybe Text
a} :: ComponentBindingPropertiesValue)

instance
  Data.FromJSON
    ComponentBindingPropertiesValue
  where
  parseJSON :: Value -> Parser ComponentBindingPropertiesValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ComponentBindingPropertiesValue"
      ( \Object
x ->
          Maybe ComponentBindingPropertiesValueProperties
-> Maybe Text -> Maybe Text -> ComponentBindingPropertiesValue
ComponentBindingPropertiesValue'
            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
"bindingProperties")
            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
"defaultValue")
            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
    ComponentBindingPropertiesValue
  where
  hashWithSalt :: Int -> ComponentBindingPropertiesValue -> Int
hashWithSalt
    Int
_salt
    ComponentBindingPropertiesValue' {Maybe Text
Maybe ComponentBindingPropertiesValueProperties
type' :: Maybe Text
defaultValue :: Maybe Text
bindingProperties :: Maybe ComponentBindingPropertiesValueProperties
$sel:type':ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
$sel:defaultValue:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
$sel:bindingProperties:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue
-> Maybe ComponentBindingPropertiesValueProperties
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ComponentBindingPropertiesValueProperties
bindingProperties
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
defaultValue
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance
  Prelude.NFData
    ComponentBindingPropertiesValue
  where
  rnf :: ComponentBindingPropertiesValue -> ()
rnf ComponentBindingPropertiesValue' {Maybe Text
Maybe ComponentBindingPropertiesValueProperties
type' :: Maybe Text
defaultValue :: Maybe Text
bindingProperties :: Maybe ComponentBindingPropertiesValueProperties
$sel:type':ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
$sel:defaultValue:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
$sel:bindingProperties:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue
-> Maybe ComponentBindingPropertiesValueProperties
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ComponentBindingPropertiesValueProperties
bindingProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
defaultValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'

instance Data.ToJSON ComponentBindingPropertiesValue where
  toJSON :: ComponentBindingPropertiesValue -> Value
toJSON ComponentBindingPropertiesValue' {Maybe Text
Maybe ComponentBindingPropertiesValueProperties
type' :: Maybe Text
defaultValue :: Maybe Text
bindingProperties :: Maybe ComponentBindingPropertiesValueProperties
$sel:type':ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
$sel:defaultValue:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue -> Maybe Text
$sel:bindingProperties:ComponentBindingPropertiesValue' :: ComponentBindingPropertiesValue
-> Maybe ComponentBindingPropertiesValueProperties
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"bindingProperties" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComponentBindingPropertiesValueProperties
bindingProperties,
            (Key
"defaultValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
defaultValue,
            (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
type'
          ]
      )