{-# 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.TruckWeight
-- 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.TruckWeight 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.VehicleWeightUnit
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the truck\'s weight specifications. Used to avoid
-- roads that can\'t support or allow the total weight for requests that
-- specify @TravelMode@ as @Truck@.
--
-- /See:/ 'newTruckWeight' smart constructor.
data TruckWeight = TruckWeight'
  { -- | The total weight of the truck.
    --
    -- -   For example, @3500@.
    TruckWeight -> Maybe Double
total :: Prelude.Maybe Prelude.Double,
    -- | The unit of measurement to use for the truck weight.
    --
    -- Default Value: @Kilograms@
    TruckWeight -> Maybe VehicleWeightUnit
unit :: Prelude.Maybe VehicleWeightUnit
  }
  deriving (TruckWeight -> TruckWeight -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TruckWeight -> TruckWeight -> Bool
$c/= :: TruckWeight -> TruckWeight -> Bool
== :: TruckWeight -> TruckWeight -> Bool
$c== :: TruckWeight -> TruckWeight -> Bool
Prelude.Eq, ReadPrec [TruckWeight]
ReadPrec TruckWeight
Int -> ReadS TruckWeight
ReadS [TruckWeight]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TruckWeight]
$creadListPrec :: ReadPrec [TruckWeight]
readPrec :: ReadPrec TruckWeight
$creadPrec :: ReadPrec TruckWeight
readList :: ReadS [TruckWeight]
$creadList :: ReadS [TruckWeight]
readsPrec :: Int -> ReadS TruckWeight
$creadsPrec :: Int -> ReadS TruckWeight
Prelude.Read, Int -> TruckWeight -> ShowS
[TruckWeight] -> ShowS
TruckWeight -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TruckWeight] -> ShowS
$cshowList :: [TruckWeight] -> ShowS
show :: TruckWeight -> String
$cshow :: TruckWeight -> String
showsPrec :: Int -> TruckWeight -> ShowS
$cshowsPrec :: Int -> TruckWeight -> ShowS
Prelude.Show, forall x. Rep TruckWeight x -> TruckWeight
forall x. TruckWeight -> Rep TruckWeight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TruckWeight x -> TruckWeight
$cfrom :: forall x. TruckWeight -> Rep TruckWeight x
Prelude.Generic)

-- |
-- Create a value of 'TruckWeight' 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:
--
-- 'total', 'truckWeight_total' - The total weight of the truck.
--
-- -   For example, @3500@.
--
-- 'unit', 'truckWeight_unit' - The unit of measurement to use for the truck weight.
--
-- Default Value: @Kilograms@
newTruckWeight ::
  TruckWeight
newTruckWeight :: TruckWeight
newTruckWeight =
  TruckWeight'
    { $sel:total:TruckWeight' :: Maybe Double
total = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:TruckWeight' :: Maybe VehicleWeightUnit
unit = forall a. Maybe a
Prelude.Nothing
    }

-- | The total weight of the truck.
--
-- -   For example, @3500@.
truckWeight_total :: Lens.Lens' TruckWeight (Prelude.Maybe Prelude.Double)
truckWeight_total :: Lens' TruckWeight (Maybe Double)
truckWeight_total = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TruckWeight' {Maybe Double
total :: Maybe Double
$sel:total:TruckWeight' :: TruckWeight -> Maybe Double
total} -> Maybe Double
total) (\s :: TruckWeight
s@TruckWeight' {} Maybe Double
a -> TruckWeight
s {$sel:total:TruckWeight' :: Maybe Double
total = Maybe Double
a} :: TruckWeight)

-- | The unit of measurement to use for the truck weight.
--
-- Default Value: @Kilograms@
truckWeight_unit :: Lens.Lens' TruckWeight (Prelude.Maybe VehicleWeightUnit)
truckWeight_unit :: Lens' TruckWeight (Maybe VehicleWeightUnit)
truckWeight_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TruckWeight' {Maybe VehicleWeightUnit
unit :: Maybe VehicleWeightUnit
$sel:unit:TruckWeight' :: TruckWeight -> Maybe VehicleWeightUnit
unit} -> Maybe VehicleWeightUnit
unit) (\s :: TruckWeight
s@TruckWeight' {} Maybe VehicleWeightUnit
a -> TruckWeight
s {$sel:unit:TruckWeight' :: Maybe VehicleWeightUnit
unit = Maybe VehicleWeightUnit
a} :: TruckWeight)

instance Prelude.Hashable TruckWeight where
  hashWithSalt :: Int -> TruckWeight -> Int
hashWithSalt Int
_salt TruckWeight' {Maybe Double
Maybe VehicleWeightUnit
unit :: Maybe VehicleWeightUnit
total :: Maybe Double
$sel:unit:TruckWeight' :: TruckWeight -> Maybe VehicleWeightUnit
$sel:total:TruckWeight' :: TruckWeight -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
total
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VehicleWeightUnit
unit

instance Prelude.NFData TruckWeight where
  rnf :: TruckWeight -> ()
rnf TruckWeight' {Maybe Double
Maybe VehicleWeightUnit
unit :: Maybe VehicleWeightUnit
total :: Maybe Double
$sel:unit:TruckWeight' :: TruckWeight -> Maybe VehicleWeightUnit
$sel:total:TruckWeight' :: TruckWeight -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
total seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VehicleWeightUnit
unit

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