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

-- | Associates a component property to a binding property. This enables
-- exposed properties on the top level component to propagate data to the
-- component\'s property values.
--
-- /See:/ 'newComponentPropertyBindingProperties' smart constructor.
data ComponentPropertyBindingProperties = ComponentPropertyBindingProperties'
  { -- | The data field to bind the property to.
    ComponentPropertyBindingProperties -> Maybe Text
field :: Prelude.Maybe Prelude.Text,
    -- | The component property to bind to the data field.
    ComponentPropertyBindingProperties -> Text
property :: Prelude.Text
  }
  deriving (ComponentPropertyBindingProperties
-> ComponentPropertyBindingProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentPropertyBindingProperties
-> ComponentPropertyBindingProperties -> Bool
$c/= :: ComponentPropertyBindingProperties
-> ComponentPropertyBindingProperties -> Bool
== :: ComponentPropertyBindingProperties
-> ComponentPropertyBindingProperties -> Bool
$c== :: ComponentPropertyBindingProperties
-> ComponentPropertyBindingProperties -> Bool
Prelude.Eq, ReadPrec [ComponentPropertyBindingProperties]
ReadPrec ComponentPropertyBindingProperties
Int -> ReadS ComponentPropertyBindingProperties
ReadS [ComponentPropertyBindingProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComponentPropertyBindingProperties]
$creadListPrec :: ReadPrec [ComponentPropertyBindingProperties]
readPrec :: ReadPrec ComponentPropertyBindingProperties
$creadPrec :: ReadPrec ComponentPropertyBindingProperties
readList :: ReadS [ComponentPropertyBindingProperties]
$creadList :: ReadS [ComponentPropertyBindingProperties]
readsPrec :: Int -> ReadS ComponentPropertyBindingProperties
$creadsPrec :: Int -> ReadS ComponentPropertyBindingProperties
Prelude.Read, Int -> ComponentPropertyBindingProperties -> ShowS
[ComponentPropertyBindingProperties] -> ShowS
ComponentPropertyBindingProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentPropertyBindingProperties] -> ShowS
$cshowList :: [ComponentPropertyBindingProperties] -> ShowS
show :: ComponentPropertyBindingProperties -> String
$cshow :: ComponentPropertyBindingProperties -> String
showsPrec :: Int -> ComponentPropertyBindingProperties -> ShowS
$cshowsPrec :: Int -> ComponentPropertyBindingProperties -> ShowS
Prelude.Show, forall x.
Rep ComponentPropertyBindingProperties x
-> ComponentPropertyBindingProperties
forall x.
ComponentPropertyBindingProperties
-> Rep ComponentPropertyBindingProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ComponentPropertyBindingProperties x
-> ComponentPropertyBindingProperties
$cfrom :: forall x.
ComponentPropertyBindingProperties
-> Rep ComponentPropertyBindingProperties x
Prelude.Generic)

-- |
-- Create a value of 'ComponentPropertyBindingProperties' 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:
--
-- 'field', 'componentPropertyBindingProperties_field' - The data field to bind the property to.
--
-- 'property', 'componentPropertyBindingProperties_property' - The component property to bind to the data field.
newComponentPropertyBindingProperties ::
  -- | 'property'
  Prelude.Text ->
  ComponentPropertyBindingProperties
newComponentPropertyBindingProperties :: Text -> ComponentPropertyBindingProperties
newComponentPropertyBindingProperties Text
pProperty_ =
  ComponentPropertyBindingProperties'
    { $sel:field:ComponentPropertyBindingProperties' :: Maybe Text
field =
        forall a. Maybe a
Prelude.Nothing,
      $sel:property:ComponentPropertyBindingProperties' :: Text
property = Text
pProperty_
    }

-- | The data field to bind the property to.
componentPropertyBindingProperties_field :: Lens.Lens' ComponentPropertyBindingProperties (Prelude.Maybe Prelude.Text)
componentPropertyBindingProperties_field :: Lens' ComponentPropertyBindingProperties (Maybe Text)
componentPropertyBindingProperties_field = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentPropertyBindingProperties' {Maybe Text
field :: Maybe Text
$sel:field:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Maybe Text
field} -> Maybe Text
field) (\s :: ComponentPropertyBindingProperties
s@ComponentPropertyBindingProperties' {} Maybe Text
a -> ComponentPropertyBindingProperties
s {$sel:field:ComponentPropertyBindingProperties' :: Maybe Text
field = Maybe Text
a} :: ComponentPropertyBindingProperties)

-- | The component property to bind to the data field.
componentPropertyBindingProperties_property :: Lens.Lens' ComponentPropertyBindingProperties Prelude.Text
componentPropertyBindingProperties_property :: Lens' ComponentPropertyBindingProperties Text
componentPropertyBindingProperties_property = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComponentPropertyBindingProperties' {Text
property :: Text
$sel:property:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Text
property} -> Text
property) (\s :: ComponentPropertyBindingProperties
s@ComponentPropertyBindingProperties' {} Text
a -> ComponentPropertyBindingProperties
s {$sel:property:ComponentPropertyBindingProperties' :: Text
property = Text
a} :: ComponentPropertyBindingProperties)

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

instance
  Prelude.Hashable
    ComponentPropertyBindingProperties
  where
  hashWithSalt :: Int -> ComponentPropertyBindingProperties -> Int
hashWithSalt
    Int
_salt
    ComponentPropertyBindingProperties' {Maybe Text
Text
property :: Text
field :: Maybe Text
$sel:property:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Text
$sel:field:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
field
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
property

instance
  Prelude.NFData
    ComponentPropertyBindingProperties
  where
  rnf :: ComponentPropertyBindingProperties -> ()
rnf ComponentPropertyBindingProperties' {Maybe Text
Text
property :: Text
field :: Maybe Text
$sel:property:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Text
$sel:field:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
field
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
property

instance
  Data.ToJSON
    ComponentPropertyBindingProperties
  where
  toJSON :: ComponentPropertyBindingProperties -> Value
toJSON ComponentPropertyBindingProperties' {Maybe Text
Text
property :: Text
field :: Maybe Text
$sel:property:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Text
$sel:field:ComponentPropertyBindingProperties' :: ComponentPropertyBindingProperties -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"field" 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
field,
            forall a. a -> Maybe a
Prelude.Just (Key
"property" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
property)
          ]
      )