{-# 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.Location.Types.RouteMatrixEntry
-- 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.Location.Types.RouteMatrixEntry 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.RouteMatrixEntryError
import qualified Amazonka.Prelude as Prelude

-- | The result for the calculated route of one @DeparturePosition@
-- @DestinationPosition@ pair.
--
-- /See:/ 'newRouteMatrixEntry' smart constructor.
data RouteMatrixEntry = RouteMatrixEntry'
  { -- | The total distance of travel for the route.
    RouteMatrixEntry -> Maybe Double
distance :: Prelude.Maybe Prelude.Double,
    -- | The expected duration of travel for the route.
    RouteMatrixEntry -> Maybe Double
durationSeconds :: Prelude.Maybe Prelude.Double,
    -- | An error corresponding to the calculation of a route between the
    -- @DeparturePosition@ and @DestinationPosition@.
    RouteMatrixEntry -> Maybe RouteMatrixEntryError
error :: Prelude.Maybe RouteMatrixEntryError
  }
  deriving (RouteMatrixEntry -> RouteMatrixEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteMatrixEntry -> RouteMatrixEntry -> Bool
$c/= :: RouteMatrixEntry -> RouteMatrixEntry -> Bool
== :: RouteMatrixEntry -> RouteMatrixEntry -> Bool
$c== :: RouteMatrixEntry -> RouteMatrixEntry -> Bool
Prelude.Eq, ReadPrec [RouteMatrixEntry]
ReadPrec RouteMatrixEntry
Int -> ReadS RouteMatrixEntry
ReadS [RouteMatrixEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteMatrixEntry]
$creadListPrec :: ReadPrec [RouteMatrixEntry]
readPrec :: ReadPrec RouteMatrixEntry
$creadPrec :: ReadPrec RouteMatrixEntry
readList :: ReadS [RouteMatrixEntry]
$creadList :: ReadS [RouteMatrixEntry]
readsPrec :: Int -> ReadS RouteMatrixEntry
$creadsPrec :: Int -> ReadS RouteMatrixEntry
Prelude.Read, Int -> RouteMatrixEntry -> ShowS
[RouteMatrixEntry] -> ShowS
RouteMatrixEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteMatrixEntry] -> ShowS
$cshowList :: [RouteMatrixEntry] -> ShowS
show :: RouteMatrixEntry -> String
$cshow :: RouteMatrixEntry -> String
showsPrec :: Int -> RouteMatrixEntry -> ShowS
$cshowsPrec :: Int -> RouteMatrixEntry -> ShowS
Prelude.Show, forall x. Rep RouteMatrixEntry x -> RouteMatrixEntry
forall x. RouteMatrixEntry -> Rep RouteMatrixEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteMatrixEntry x -> RouteMatrixEntry
$cfrom :: forall x. RouteMatrixEntry -> Rep RouteMatrixEntry x
Prelude.Generic)

-- |
-- Create a value of 'RouteMatrixEntry' 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:
--
-- 'distance', 'routeMatrixEntry_distance' - The total distance of travel for the route.
--
-- 'durationSeconds', 'routeMatrixEntry_durationSeconds' - The expected duration of travel for the route.
--
-- 'error', 'routeMatrixEntry_error' - An error corresponding to the calculation of a route between the
-- @DeparturePosition@ and @DestinationPosition@.
newRouteMatrixEntry ::
  RouteMatrixEntry
newRouteMatrixEntry :: RouteMatrixEntry
newRouteMatrixEntry =
  RouteMatrixEntry'
    { $sel:distance:RouteMatrixEntry' :: Maybe Double
distance = forall a. Maybe a
Prelude.Nothing,
      $sel:durationSeconds:RouteMatrixEntry' :: Maybe Double
durationSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:error:RouteMatrixEntry' :: Maybe RouteMatrixEntryError
error = forall a. Maybe a
Prelude.Nothing
    }

-- | The total distance of travel for the route.
routeMatrixEntry_distance :: Lens.Lens' RouteMatrixEntry (Prelude.Maybe Prelude.Double)
routeMatrixEntry_distance :: Lens' RouteMatrixEntry (Maybe Double)
routeMatrixEntry_distance = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteMatrixEntry' {Maybe Double
distance :: Maybe Double
$sel:distance:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe Double
distance} -> Maybe Double
distance) (\s :: RouteMatrixEntry
s@RouteMatrixEntry' {} Maybe Double
a -> RouteMatrixEntry
s {$sel:distance:RouteMatrixEntry' :: Maybe Double
distance = Maybe Double
a} :: RouteMatrixEntry)

-- | The expected duration of travel for the route.
routeMatrixEntry_durationSeconds :: Lens.Lens' RouteMatrixEntry (Prelude.Maybe Prelude.Double)
routeMatrixEntry_durationSeconds :: Lens' RouteMatrixEntry (Maybe Double)
routeMatrixEntry_durationSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteMatrixEntry' {Maybe Double
durationSeconds :: Maybe Double
$sel:durationSeconds:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe Double
durationSeconds} -> Maybe Double
durationSeconds) (\s :: RouteMatrixEntry
s@RouteMatrixEntry' {} Maybe Double
a -> RouteMatrixEntry
s {$sel:durationSeconds:RouteMatrixEntry' :: Maybe Double
durationSeconds = Maybe Double
a} :: RouteMatrixEntry)

-- | An error corresponding to the calculation of a route between the
-- @DeparturePosition@ and @DestinationPosition@.
routeMatrixEntry_error :: Lens.Lens' RouteMatrixEntry (Prelude.Maybe RouteMatrixEntryError)
routeMatrixEntry_error :: Lens' RouteMatrixEntry (Maybe RouteMatrixEntryError)
routeMatrixEntry_error = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteMatrixEntry' {Maybe RouteMatrixEntryError
error :: Maybe RouteMatrixEntryError
$sel:error:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe RouteMatrixEntryError
error} -> Maybe RouteMatrixEntryError
error) (\s :: RouteMatrixEntry
s@RouteMatrixEntry' {} Maybe RouteMatrixEntryError
a -> RouteMatrixEntry
s {$sel:error:RouteMatrixEntry' :: Maybe RouteMatrixEntryError
error = Maybe RouteMatrixEntryError
a} :: RouteMatrixEntry)

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

instance Prelude.Hashable RouteMatrixEntry where
  hashWithSalt :: Int -> RouteMatrixEntry -> Int
hashWithSalt Int
_salt RouteMatrixEntry' {Maybe Double
Maybe RouteMatrixEntryError
error :: Maybe RouteMatrixEntryError
durationSeconds :: Maybe Double
distance :: Maybe Double
$sel:error:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe RouteMatrixEntryError
$sel:durationSeconds:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe Double
$sel:distance:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
distance
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
durationSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RouteMatrixEntryError
error

instance Prelude.NFData RouteMatrixEntry where
  rnf :: RouteMatrixEntry -> ()
rnf RouteMatrixEntry' {Maybe Double
Maybe RouteMatrixEntryError
error :: Maybe RouteMatrixEntryError
durationSeconds :: Maybe Double
distance :: Maybe Double
$sel:error:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe RouteMatrixEntryError
$sel:durationSeconds:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe Double
$sel:distance:RouteMatrixEntry' :: RouteMatrixEntry -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
distance
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
durationSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteMatrixEntryError
error