{-# 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 #-}
module Amazonka.Location.Types.Leg where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Location.Types.LegGeometry
import Amazonka.Location.Types.Step
import qualified Amazonka.Prelude as Prelude
data Leg = Leg'
{
Leg -> Maybe LegGeometry
geometry :: Prelude.Maybe LegGeometry,
Leg -> Double
distance :: Prelude.Double,
Leg -> Double
durationSeconds :: Prelude.Double,
Leg -> Sensitive (NonEmpty Double)
endPosition :: Data.Sensitive (Prelude.NonEmpty Prelude.Double),
Leg -> Sensitive (NonEmpty Double)
startPosition :: Data.Sensitive (Prelude.NonEmpty Prelude.Double),
Leg -> [Step]
steps :: [Step]
}
deriving (Leg -> Leg -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Leg -> Leg -> Bool
$c/= :: Leg -> Leg -> Bool
== :: Leg -> Leg -> Bool
$c== :: Leg -> Leg -> Bool
Prelude.Eq, Int -> Leg -> ShowS
[Leg] -> ShowS
Leg -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Leg] -> ShowS
$cshowList :: [Leg] -> ShowS
show :: Leg -> String
$cshow :: Leg -> String
showsPrec :: Int -> Leg -> ShowS
$cshowsPrec :: Int -> Leg -> ShowS
Prelude.Show, forall x. Rep Leg x -> Leg
forall x. Leg -> Rep Leg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Leg x -> Leg
$cfrom :: forall x. Leg -> Rep Leg x
Prelude.Generic)
newLeg ::
Prelude.Double ->
Prelude.Double ->
Prelude.NonEmpty Prelude.Double ->
Prelude.NonEmpty Prelude.Double ->
Leg
newLeg :: Double -> Double -> NonEmpty Double -> NonEmpty Double -> Leg
newLeg
Double
pDistance_
Double
pDurationSeconds_
NonEmpty Double
pEndPosition_
NonEmpty Double
pStartPosition_ =
Leg'
{ $sel:geometry:Leg' :: Maybe LegGeometry
geometry = forall a. Maybe a
Prelude.Nothing,
$sel:distance:Leg' :: Double
distance = Double
pDistance_,
$sel:durationSeconds:Leg' :: Double
durationSeconds = Double
pDurationSeconds_,
$sel:endPosition:Leg' :: Sensitive (NonEmpty Double)
endPosition =
forall a. Iso' (Sensitive a) a
Data._Sensitive
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pEndPosition_,
$sel:startPosition:Leg' :: Sensitive (NonEmpty Double)
startPosition =
forall a. Iso' (Sensitive a) a
Data._Sensitive
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pStartPosition_,
$sel:steps:Leg' :: [Step]
steps = forall a. Monoid a => a
Prelude.mempty
}
leg_geometry :: Lens.Lens' Leg (Prelude.Maybe LegGeometry)
leg_geometry :: Lens' Leg (Maybe LegGeometry)
leg_geometry = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Maybe LegGeometry
geometry :: Maybe LegGeometry
$sel:geometry:Leg' :: Leg -> Maybe LegGeometry
geometry} -> Maybe LegGeometry
geometry) (\s :: Leg
s@Leg' {} Maybe LegGeometry
a -> Leg
s {$sel:geometry:Leg' :: Maybe LegGeometry
geometry = Maybe LegGeometry
a} :: Leg)
leg_distance :: Lens.Lens' Leg Prelude.Double
leg_distance :: Lens' Leg Double
leg_distance = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Double
distance :: Double
$sel:distance:Leg' :: Leg -> Double
distance} -> Double
distance) (\s :: Leg
s@Leg' {} Double
a -> Leg
s {$sel:distance:Leg' :: Double
distance = Double
a} :: Leg)
leg_durationSeconds :: Lens.Lens' Leg Prelude.Double
leg_durationSeconds :: Lens' Leg Double
leg_durationSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Double
durationSeconds :: Double
$sel:durationSeconds:Leg' :: Leg -> Double
durationSeconds} -> Double
durationSeconds) (\s :: Leg
s@Leg' {} Double
a -> Leg
s {$sel:durationSeconds:Leg' :: Double
durationSeconds = Double
a} :: Leg)
leg_endPosition :: Lens.Lens' Leg (Prelude.NonEmpty Prelude.Double)
leg_endPosition :: Lens' Leg (NonEmpty Double)
leg_endPosition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Sensitive (NonEmpty Double)
endPosition :: Sensitive (NonEmpty Double)
$sel:endPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
endPosition} -> Sensitive (NonEmpty Double)
endPosition) (\s :: Leg
s@Leg' {} Sensitive (NonEmpty Double)
a -> Leg
s {$sel:endPosition:Leg' :: Sensitive (NonEmpty Double)
endPosition = Sensitive (NonEmpty Double)
a} :: Leg) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
leg_startPosition :: Lens.Lens' Leg (Prelude.NonEmpty Prelude.Double)
leg_startPosition :: Lens' Leg (NonEmpty Double)
leg_startPosition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {Sensitive (NonEmpty Double)
startPosition :: Sensitive (NonEmpty Double)
$sel:startPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
startPosition} -> Sensitive (NonEmpty Double)
startPosition) (\s :: Leg
s@Leg' {} Sensitive (NonEmpty Double)
a -> Leg
s {$sel:startPosition:Leg' :: Sensitive (NonEmpty Double)
startPosition = Sensitive (NonEmpty Double)
a} :: Leg) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
leg_steps :: Lens.Lens' Leg [Step]
leg_steps :: Lens' Leg [Step]
leg_steps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Leg' {[Step]
steps :: [Step]
$sel:steps:Leg' :: Leg -> [Step]
steps} -> [Step]
steps) (\s :: Leg
s@Leg' {} [Step]
a -> Leg
s {$sel:steps:Leg' :: [Step]
steps = [Step]
a} :: Leg) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Data.FromJSON Leg where
parseJSON :: Value -> Parser Leg
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Leg"
( \Object
x ->
Maybe LegGeometry
-> Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> [Step]
-> Leg
Leg'
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
"Geometry")
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
"Distance")
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
"DurationSeconds")
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
"EndPosition")
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
"StartPosition")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Steps" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable Leg where
hashWithSalt :: Int -> Leg -> Int
hashWithSalt Int
_salt Leg' {Double
[Step]
Maybe LegGeometry
Sensitive (NonEmpty Double)
steps :: [Step]
startPosition :: Sensitive (NonEmpty Double)
endPosition :: Sensitive (NonEmpty Double)
durationSeconds :: Double
distance :: Double
geometry :: Maybe LegGeometry
$sel:steps:Leg' :: Leg -> [Step]
$sel:startPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
$sel:endPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
$sel:durationSeconds:Leg' :: Leg -> Double
$sel:distance:Leg' :: Leg -> Double
$sel:geometry:Leg' :: Leg -> Maybe LegGeometry
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LegGeometry
geometry
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
distance
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
durationSeconds
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive (NonEmpty Double)
endPosition
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive (NonEmpty Double)
startPosition
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Step]
steps
instance Prelude.NFData Leg where
rnf :: Leg -> ()
rnf Leg' {Double
[Step]
Maybe LegGeometry
Sensitive (NonEmpty Double)
steps :: [Step]
startPosition :: Sensitive (NonEmpty Double)
endPosition :: Sensitive (NonEmpty Double)
durationSeconds :: Double
distance :: Double
geometry :: Maybe LegGeometry
$sel:steps:Leg' :: Leg -> [Step]
$sel:startPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
$sel:endPosition:Leg' :: Leg -> Sensitive (NonEmpty Double)
$sel:durationSeconds:Leg' :: Leg -> Double
$sel:distance:Leg' :: Leg -> Double
$sel:geometry:Leg' :: Leg -> Maybe LegGeometry
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe LegGeometry
geometry
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
distance
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
durationSeconds
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive (NonEmpty Double)
endPosition
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive (NonEmpty Double)
startPosition
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Step]
steps