{-# 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.IoTRoboRunner.Types.Orientation
-- 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.IoTRoboRunner.Types.Orientation 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

-- | Worker orientation measured in units clockwise from north.
--
-- /See:/ 'newOrientation' smart constructor.
data Orientation = Orientation'
  { -- | Degrees, limited on [0, 360)
    Orientation -> Maybe Double
degrees :: Prelude.Maybe Prelude.Double
  }
  deriving (Orientation -> Orientation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Orientation -> Orientation -> Bool
$c/= :: Orientation -> Orientation -> Bool
== :: Orientation -> Orientation -> Bool
$c== :: Orientation -> Orientation -> Bool
Prelude.Eq, ReadPrec [Orientation]
ReadPrec Orientation
Int -> ReadS Orientation
ReadS [Orientation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Orientation]
$creadListPrec :: ReadPrec [Orientation]
readPrec :: ReadPrec Orientation
$creadPrec :: ReadPrec Orientation
readList :: ReadS [Orientation]
$creadList :: ReadS [Orientation]
readsPrec :: Int -> ReadS Orientation
$creadsPrec :: Int -> ReadS Orientation
Prelude.Read, Int -> Orientation -> ShowS
[Orientation] -> ShowS
Orientation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Orientation] -> ShowS
$cshowList :: [Orientation] -> ShowS
show :: Orientation -> String
$cshow :: Orientation -> String
showsPrec :: Int -> Orientation -> ShowS
$cshowsPrec :: Int -> Orientation -> ShowS
Prelude.Show, forall x. Rep Orientation x -> Orientation
forall x. Orientation -> Rep Orientation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Orientation x -> Orientation
$cfrom :: forall x. Orientation -> Rep Orientation x
Prelude.Generic)

-- |
-- Create a value of 'Orientation' 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:
--
-- 'degrees', 'orientation_degrees' - Degrees, limited on [0, 360)
newOrientation ::
  Orientation
newOrientation :: Orientation
newOrientation =
  Orientation' {$sel:degrees:Orientation' :: Maybe Double
degrees = forall a. Maybe a
Prelude.Nothing}

-- | Degrees, limited on [0, 360)
orientation_degrees :: Lens.Lens' Orientation (Prelude.Maybe Prelude.Double)
orientation_degrees :: Lens' Orientation (Maybe Double)
orientation_degrees = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Orientation' {Maybe Double
degrees :: Maybe Double
$sel:degrees:Orientation' :: Orientation -> Maybe Double
degrees} -> Maybe Double
degrees) (\s :: Orientation
s@Orientation' {} Maybe Double
a -> Orientation
s {$sel:degrees:Orientation' :: Maybe Double
degrees = Maybe Double
a} :: Orientation)

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

instance Prelude.Hashable Orientation where
  hashWithSalt :: Int -> Orientation -> Int
hashWithSalt Int
_salt Orientation' {Maybe Double
degrees :: Maybe Double
$sel:degrees:Orientation' :: Orientation -> Maybe Double
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
degrees

instance Prelude.NFData Orientation where
  rnf :: Orientation -> ()
rnf Orientation' {Maybe Double
degrees :: Maybe Double
$sel:degrees:Orientation' :: Orientation -> Maybe Double
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
degrees

instance Data.ToJSON Orientation where
  toJSON :: Orientation -> Value
toJSON Orientation' {Maybe Double
degrees :: Maybe Double
$sel:degrees:Orientation' :: Orientation -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"degrees" 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 Double
degrees]
      )