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

-- | Describes how to bind a component property to form data.
--
-- /See:/ 'newFormBindingElement' smart constructor.
data FormBindingElement = FormBindingElement'
  { -- | The name of the component to retrieve a value from.
    FormBindingElement -> Text
element :: Prelude.Text,
    -- | The property to retrieve a value from.
    FormBindingElement -> Text
property :: Prelude.Text
  }
  deriving (FormBindingElement -> FormBindingElement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FormBindingElement -> FormBindingElement -> Bool
$c/= :: FormBindingElement -> FormBindingElement -> Bool
== :: FormBindingElement -> FormBindingElement -> Bool
$c== :: FormBindingElement -> FormBindingElement -> Bool
Prelude.Eq, ReadPrec [FormBindingElement]
ReadPrec FormBindingElement
Int -> ReadS FormBindingElement
ReadS [FormBindingElement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FormBindingElement]
$creadListPrec :: ReadPrec [FormBindingElement]
readPrec :: ReadPrec FormBindingElement
$creadPrec :: ReadPrec FormBindingElement
readList :: ReadS [FormBindingElement]
$creadList :: ReadS [FormBindingElement]
readsPrec :: Int -> ReadS FormBindingElement
$creadsPrec :: Int -> ReadS FormBindingElement
Prelude.Read, Int -> FormBindingElement -> ShowS
[FormBindingElement] -> ShowS
FormBindingElement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FormBindingElement] -> ShowS
$cshowList :: [FormBindingElement] -> ShowS
show :: FormBindingElement -> String
$cshow :: FormBindingElement -> String
showsPrec :: Int -> FormBindingElement -> ShowS
$cshowsPrec :: Int -> FormBindingElement -> ShowS
Prelude.Show, forall x. Rep FormBindingElement x -> FormBindingElement
forall x. FormBindingElement -> Rep FormBindingElement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FormBindingElement x -> FormBindingElement
$cfrom :: forall x. FormBindingElement -> Rep FormBindingElement x
Prelude.Generic)

-- |
-- Create a value of 'FormBindingElement' 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:
--
-- 'element', 'formBindingElement_element' - The name of the component to retrieve a value from.
--
-- 'property', 'formBindingElement_property' - The property to retrieve a value from.
newFormBindingElement ::
  -- | 'element'
  Prelude.Text ->
  -- | 'property'
  Prelude.Text ->
  FormBindingElement
newFormBindingElement :: Text -> Text -> FormBindingElement
newFormBindingElement Text
pElement_ Text
pProperty_ =
  FormBindingElement'
    { $sel:element:FormBindingElement' :: Text
element = Text
pElement_,
      $sel:property:FormBindingElement' :: Text
property = Text
pProperty_
    }

-- | The name of the component to retrieve a value from.
formBindingElement_element :: Lens.Lens' FormBindingElement Prelude.Text
formBindingElement_element :: Lens' FormBindingElement Text
formBindingElement_element = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormBindingElement' {Text
element :: Text
$sel:element:FormBindingElement' :: FormBindingElement -> Text
element} -> Text
element) (\s :: FormBindingElement
s@FormBindingElement' {} Text
a -> FormBindingElement
s {$sel:element:FormBindingElement' :: Text
element = Text
a} :: FormBindingElement)

-- | The property to retrieve a value from.
formBindingElement_property :: Lens.Lens' FormBindingElement Prelude.Text
formBindingElement_property :: Lens' FormBindingElement Text
formBindingElement_property = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormBindingElement' {Text
property :: Text
$sel:property:FormBindingElement' :: FormBindingElement -> Text
property} -> Text
property) (\s :: FormBindingElement
s@FormBindingElement' {} Text
a -> FormBindingElement
s {$sel:property:FormBindingElement' :: Text
property = Text
a} :: FormBindingElement)

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

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

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