{-# 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.RobOMaker.Types.WorldConfig
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RobOMaker.Types.WorldConfig where

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

-- | Configuration information for a world.
--
-- /See:/ 'newWorldConfig' smart constructor.
data WorldConfig = WorldConfig'
  { -- | The world generated by Simulation WorldForge.
    WorldConfig -> Maybe Text
world :: Prelude.Maybe Prelude.Text
  }
  deriving (WorldConfig -> WorldConfig -> Bool
(WorldConfig -> WorldConfig -> Bool)
-> (WorldConfig -> WorldConfig -> Bool) -> Eq WorldConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorldConfig -> WorldConfig -> Bool
$c/= :: WorldConfig -> WorldConfig -> Bool
== :: WorldConfig -> WorldConfig -> Bool
$c== :: WorldConfig -> WorldConfig -> Bool
Prelude.Eq, ReadPrec [WorldConfig]
ReadPrec WorldConfig
Int -> ReadS WorldConfig
ReadS [WorldConfig]
(Int -> ReadS WorldConfig)
-> ReadS [WorldConfig]
-> ReadPrec WorldConfig
-> ReadPrec [WorldConfig]
-> Read WorldConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorldConfig]
$creadListPrec :: ReadPrec [WorldConfig]
readPrec :: ReadPrec WorldConfig
$creadPrec :: ReadPrec WorldConfig
readList :: ReadS [WorldConfig]
$creadList :: ReadS [WorldConfig]
readsPrec :: Int -> ReadS WorldConfig
$creadsPrec :: Int -> ReadS WorldConfig
Prelude.Read, Int -> WorldConfig -> ShowS
[WorldConfig] -> ShowS
WorldConfig -> String
(Int -> WorldConfig -> ShowS)
-> (WorldConfig -> String)
-> ([WorldConfig] -> ShowS)
-> Show WorldConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorldConfig] -> ShowS
$cshowList :: [WorldConfig] -> ShowS
show :: WorldConfig -> String
$cshow :: WorldConfig -> String
showsPrec :: Int -> WorldConfig -> ShowS
$cshowsPrec :: Int -> WorldConfig -> ShowS
Prelude.Show, (forall x. WorldConfig -> Rep WorldConfig x)
-> (forall x. Rep WorldConfig x -> WorldConfig)
-> Generic WorldConfig
forall x. Rep WorldConfig x -> WorldConfig
forall x. WorldConfig -> Rep WorldConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorldConfig x -> WorldConfig
$cfrom :: forall x. WorldConfig -> Rep WorldConfig x
Prelude.Generic)

-- |
-- Create a value of 'WorldConfig' 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:
--
-- 'world', 'worldConfig_world' - The world generated by Simulation WorldForge.
newWorldConfig ::
  WorldConfig
newWorldConfig :: WorldConfig
newWorldConfig =
  WorldConfig' :: Maybe Text -> WorldConfig
WorldConfig' {$sel:world:WorldConfig' :: Maybe Text
world = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The world generated by Simulation WorldForge.
worldConfig_world :: Lens.Lens' WorldConfig (Prelude.Maybe Prelude.Text)
worldConfig_world :: (Maybe Text -> f (Maybe Text)) -> WorldConfig -> f WorldConfig
worldConfig_world = (WorldConfig -> Maybe Text)
-> (WorldConfig -> Maybe Text -> WorldConfig)
-> Lens WorldConfig WorldConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorldConfig' {Maybe Text
world :: Maybe Text
$sel:world:WorldConfig' :: WorldConfig -> Maybe Text
world} -> Maybe Text
world) (\s :: WorldConfig
s@WorldConfig' {} Maybe Text
a -> WorldConfig
s {$sel:world:WorldConfig' :: Maybe Text
world = Maybe Text
a} :: WorldConfig)

instance Core.FromJSON WorldConfig where
  parseJSON :: Value -> Parser WorldConfig
parseJSON =
    String
-> (Object -> Parser WorldConfig) -> Value -> Parser WorldConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorldConfig"
      ( \Object
x ->
          Maybe Text -> WorldConfig
WorldConfig' (Maybe Text -> WorldConfig)
-> Parser (Maybe Text) -> Parser WorldConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"world")
      )

instance Prelude.Hashable WorldConfig

instance Prelude.NFData WorldConfig

instance Core.ToJSON WorldConfig where
  toJSON :: WorldConfig -> Value
toJSON WorldConfig' {Maybe Text
world :: Maybe Text
$sel:world:WorldConfig' :: WorldConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"world" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
world]
      )