{-# 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.IoTFleetWise.Types.Branch
-- 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.IoTFleetWise.Types.Branch 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

-- | A group of signals that are defined in a hierarchical structure.
--
-- /See:/ 'newBranch' smart constructor.
data Branch = Branch'
  { -- | A brief description of the branch.
    Branch -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The fully qualified name of the branch. For example, the fully qualified
    -- name of a branch might be @Vehicle.Body.Engine@.
    Branch -> Text
fullyQualifiedName :: Prelude.Text
  }
  deriving (Branch -> Branch -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Branch -> Branch -> Bool
$c/= :: Branch -> Branch -> Bool
== :: Branch -> Branch -> Bool
$c== :: Branch -> Branch -> Bool
Prelude.Eq, ReadPrec [Branch]
ReadPrec Branch
Int -> ReadS Branch
ReadS [Branch]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Branch]
$creadListPrec :: ReadPrec [Branch]
readPrec :: ReadPrec Branch
$creadPrec :: ReadPrec Branch
readList :: ReadS [Branch]
$creadList :: ReadS [Branch]
readsPrec :: Int -> ReadS Branch
$creadsPrec :: Int -> ReadS Branch
Prelude.Read, Int -> Branch -> ShowS
[Branch] -> ShowS
Branch -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Branch] -> ShowS
$cshowList :: [Branch] -> ShowS
show :: Branch -> String
$cshow :: Branch -> String
showsPrec :: Int -> Branch -> ShowS
$cshowsPrec :: Int -> Branch -> ShowS
Prelude.Show, forall x. Rep Branch x -> Branch
forall x. Branch -> Rep Branch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Branch x -> Branch
$cfrom :: forall x. Branch -> Rep Branch x
Prelude.Generic)

-- |
-- Create a value of 'Branch' 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:
--
-- 'description', 'branch_description' - A brief description of the branch.
--
-- 'fullyQualifiedName', 'branch_fullyQualifiedName' - The fully qualified name of the branch. For example, the fully qualified
-- name of a branch might be @Vehicle.Body.Engine@.
newBranch ::
  -- | 'fullyQualifiedName'
  Prelude.Text ->
  Branch
newBranch :: Text -> Branch
newBranch Text
pFullyQualifiedName_ =
  Branch'
    { $sel:description:Branch' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:fullyQualifiedName:Branch' :: Text
fullyQualifiedName = Text
pFullyQualifiedName_
    }

-- | A brief description of the branch.
branch_description :: Lens.Lens' Branch (Prelude.Maybe Prelude.Text)
branch_description :: Lens' Branch (Maybe Text)
branch_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Branch' {Maybe Text
description :: Maybe Text
$sel:description:Branch' :: Branch -> Maybe Text
description} -> Maybe Text
description) (\s :: Branch
s@Branch' {} Maybe Text
a -> Branch
s {$sel:description:Branch' :: Maybe Text
description = Maybe Text
a} :: Branch)

-- | The fully qualified name of the branch. For example, the fully qualified
-- name of a branch might be @Vehicle.Body.Engine@.
branch_fullyQualifiedName :: Lens.Lens' Branch Prelude.Text
branch_fullyQualifiedName :: Lens' Branch Text
branch_fullyQualifiedName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Branch' {Text
fullyQualifiedName :: Text
$sel:fullyQualifiedName:Branch' :: Branch -> Text
fullyQualifiedName} -> Text
fullyQualifiedName) (\s :: Branch
s@Branch' {} Text
a -> Branch
s {$sel:fullyQualifiedName:Branch' :: Text
fullyQualifiedName = Text
a} :: Branch)

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

instance Prelude.Hashable Branch where
  hashWithSalt :: Int -> Branch -> Int
hashWithSalt Int
_salt Branch' {Maybe Text
Text
fullyQualifiedName :: Text
description :: Maybe Text
$sel:fullyQualifiedName:Branch' :: Branch -> Text
$sel:description:Branch' :: Branch -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fullyQualifiedName

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

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