software.amazon.awssdk.services.location.model.CalculateRouteMatrixRequest Maven / Gradle / Ivy
Show all versions of location Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.location.model;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.TimestampFormatTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class CalculateRouteMatrixRequest extends LocationRequest implements
ToCopyableBuilder {
private static final SdkField CALCULATOR_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CalculatorName").getter(getter(CalculateRouteMatrixRequest::calculatorName))
.setter(setter(Builder::calculatorName))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("CalculatorName").build()).build();
private static final SdkField>> DEPARTURE_POSITIONS_FIELD = SdkField
.>> builder(MarshallingType.LIST)
.memberName("DeparturePositions")
.getter(getter(CalculateRouteMatrixRequest::departurePositions))
.setter(setter(Builder::departurePositions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DeparturePositions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField.> builder(MarshallingType.LIST)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.DOUBLE)
.traits(LocationTrait.builder()
.location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build())
.build()).build()).build()).build();
private static final SdkField>> DESTINATION_POSITIONS_FIELD = SdkField
.>> builder(MarshallingType.LIST)
.memberName("DestinationPositions")
.getter(getter(CalculateRouteMatrixRequest::destinationPositions))
.setter(setter(Builder::destinationPositions))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DestinationPositions").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField.> builder(MarshallingType.LIST)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.DOUBLE)
.traits(LocationTrait.builder()
.location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build())
.build()).build()).build()).build();
private static final SdkField TRAVEL_MODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TravelMode").getter(getter(CalculateRouteMatrixRequest::travelModeAsString))
.setter(setter(Builder::travelMode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TravelMode").build()).build();
private static final SdkField DEPARTURE_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("DepartureTime")
.getter(getter(CalculateRouteMatrixRequest::departureTime))
.setter(setter(Builder::departureTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DepartureTime").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField DEPART_NOW_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("DepartNow").getter(getter(CalculateRouteMatrixRequest::departNow)).setter(setter(Builder::departNow))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DepartNow").build()).build();
private static final SdkField DISTANCE_UNIT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DistanceUnit").getter(getter(CalculateRouteMatrixRequest::distanceUnitAsString))
.setter(setter(Builder::distanceUnit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DistanceUnit").build()).build();
private static final SdkField CAR_MODE_OPTIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("CarModeOptions")
.getter(getter(CalculateRouteMatrixRequest::carModeOptions)).setter(setter(Builder::carModeOptions))
.constructor(CalculateRouteCarModeOptions::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CarModeOptions").build()).build();
private static final SdkField TRUCK_MODE_OPTIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TruckModeOptions")
.getter(getter(CalculateRouteMatrixRequest::truckModeOptions)).setter(setter(Builder::truckModeOptions))
.constructor(CalculateRouteTruckModeOptions::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TruckModeOptions").build()).build();
private static final SdkField KEY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Key")
.getter(getter(CalculateRouteMatrixRequest::key)).setter(setter(Builder::key))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("key").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CALCULATOR_NAME_FIELD,
DEPARTURE_POSITIONS_FIELD, DESTINATION_POSITIONS_FIELD, TRAVEL_MODE_FIELD, DEPARTURE_TIME_FIELD, DEPART_NOW_FIELD,
DISTANCE_UNIT_FIELD, CAR_MODE_OPTIONS_FIELD, TRUCK_MODE_OPTIONS_FIELD, KEY_FIELD));
private final String calculatorName;
private final List> departurePositions;
private final List> destinationPositions;
private final String travelMode;
private final Instant departureTime;
private final Boolean departNow;
private final String distanceUnit;
private final CalculateRouteCarModeOptions carModeOptions;
private final CalculateRouteTruckModeOptions truckModeOptions;
private final String key;
private CalculateRouteMatrixRequest(BuilderImpl builder) {
super(builder);
this.calculatorName = builder.calculatorName;
this.departurePositions = builder.departurePositions;
this.destinationPositions = builder.destinationPositions;
this.travelMode = builder.travelMode;
this.departureTime = builder.departureTime;
this.departNow = builder.departNow;
this.distanceUnit = builder.distanceUnit;
this.carModeOptions = builder.carModeOptions;
this.truckModeOptions = builder.truckModeOptions;
this.key = builder.key;
}
/**
*
* The name of the route calculator resource that you want to use to calculate the route matrix.
*
*
* @return The name of the route calculator resource that you want to use to calculate the route matrix.
*/
public final String calculatorName() {
return calculatorName;
}
/**
* For responses, this returns true if the service returned a value for the DeparturePositions property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasDeparturePositions() {
return departurePositions != null && !(departurePositions instanceof SdkAutoConstructList);
}
/**
*
* The list of departure (origin) positions for the route matrix. An array of points, each of which is itself a
* 2-value array defined in WGS 84 format:
* [longitude, latitude]
. For example, [-123.115, 49.285]
.
*
*
*
* Depending on the data provider selected in the route calculator resource there may be additional restrictions on
* the inputs you can choose. See Position restrictions in the Amazon Location Service Developer Guide.
*
*
*
* For route calculators that use Esri as the data provider, if you specify a departure that's not located on a
* road, Amazon Location moves the position to
* the nearest road. The snapped value is available in the result in SnappedDeparturePositions
.
*
*
*
* Valid Values: [-180 to 180,-90 to 90]
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasDeparturePositions} method.
*
*
* @return The list of departure (origin) positions for the route matrix. An array of points, each of which is
* itself a 2-value array defined in WGS 84
* format: [longitude, latitude]
. For example, [-123.115, 49.285]
.
*
* Depending on the data provider selected in the route calculator resource there may be additional
* restrictions on the inputs you can choose. See Position restrictions in the Amazon Location Service Developer Guide.
*
*
*
* For route calculators that use Esri as the data provider, if you specify a departure that's not located
* on a road, Amazon Location moves the
* position to the nearest road. The snapped value is available in the result in
* SnappedDeparturePositions
.
*
*
*
* Valid Values: [-180 to 180,-90 to 90]
*/
public final List> departurePositions() {
return departurePositions;
}
/**
* For responses, this returns true if the service returned a value for the DestinationPositions property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasDestinationPositions() {
return destinationPositions != null && !(destinationPositions instanceof SdkAutoConstructList);
}
/**
*
* The list of destination positions for the route matrix. An array of points, each of which is itself a 2-value
* array defined in WGS 84 format:
* [longitude, latitude]
. For example, [-122.339, 47.615]
*
*
*
* Depending on the data provider selected in the route calculator resource there may be additional restrictions on
* the inputs you can choose. See Position restrictions in the Amazon Location Service Developer Guide.
*
*
*
* For route calculators that use Esri as the data provider, if you specify a destination that's not located on a
* road, Amazon Location moves the position to
* the nearest road. The snapped value is available in the result in SnappedDestinationPositions
.
*
*
*
* Valid Values: [-180 to 180,-90 to 90]
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasDestinationPositions} method.
*
*
* @return The list of destination positions for the route matrix. An array of points, each of which is itself a
* 2-value array defined in WGS 84 format:
* [longitude, latitude]
. For example, [-122.339, 47.615]
*
* Depending on the data provider selected in the route calculator resource there may be additional
* restrictions on the inputs you can choose. See Position restrictions in the Amazon Location Service Developer Guide.
*
*
*
* For route calculators that use Esri as the data provider, if you specify a destination that's not located
* on a road, Amazon Location moves the
* position to the nearest road. The snapped value is available in the result in
* SnappedDestinationPositions
.
*
*
*
* Valid Values: [-180 to 180,-90 to 90]
*/
public final List> destinationPositions() {
return destinationPositions;
}
/**
*
* Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road
* compatibility.
*
*
* The TravelMode
you specify also determines how you specify route preferences:
*
*
* -
*
* If traveling by Car
use the CarModeOptions
parameter.
*
*
* -
*
* If traveling by Truck
use the TruckModeOptions
parameter.
*
*
*
*
*
* Bicycle
or Motorcycle
are only valid when using Grab
as a data provider,
* and only within Southeast Asia.
*
*
* Truck
is not available for Grab.
*
*
* For more information about using Grab as a data provider, see GrabMaps in the Amazon
* Location Service Developer Guide.
*
*
*
* Default Value: Car
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #travelMode} will
* return {@link TravelMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #travelModeAsString}.
*
*
* @return Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road
* compatibility.
*
* The TravelMode
you specify also determines how you specify route preferences:
*
*
* -
*
* If traveling by Car
use the CarModeOptions
parameter.
*
*
* -
*
* If traveling by Truck
use the TruckModeOptions
parameter.
*
*
*
*
*
* Bicycle
or Motorcycle
are only valid when using Grab
as a data
* provider, and only within Southeast Asia.
*
*
* Truck
is not available for Grab.
*
*
* For more information about using Grab as a data provider, see GrabMaps in the Amazon
* Location Service Developer Guide.
*
*
*
* Default Value: Car
* @see TravelMode
*/
public final TravelMode travelMode() {
return TravelMode.fromValue(travelMode);
}
/**
*
* Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road
* compatibility.
*
*
* The TravelMode
you specify also determines how you specify route preferences:
*
*
* -
*
* If traveling by Car
use the CarModeOptions
parameter.
*
*
* -
*
* If traveling by Truck
use the TruckModeOptions
parameter.
*
*
*
*
*
* Bicycle
or Motorcycle
are only valid when using Grab
as a data provider,
* and only within Southeast Asia.
*
*
* Truck
is not available for Grab.
*
*
* For more information about using Grab as a data provider, see GrabMaps in the Amazon
* Location Service Developer Guide.
*
*
*
* Default Value: Car
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #travelMode} will
* return {@link TravelMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #travelModeAsString}.
*
*
* @return Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road
* compatibility.
*
* The TravelMode
you specify also determines how you specify route preferences:
*
*
* -
*
* If traveling by Car
use the CarModeOptions
parameter.
*
*
* -
*
* If traveling by Truck
use the TruckModeOptions
parameter.
*
*
*
*
*
* Bicycle
or Motorcycle
are only valid when using Grab
as a data
* provider, and only within Southeast Asia.
*
*
* Truck
is not available for Grab.
*
*
* For more information about using Grab as a data provider, see GrabMaps in the Amazon
* Location Service Developer Guide.
*
*
*
* Default Value: Car
* @see TravelMode
*/
public final String travelModeAsString() {
return travelMode;
}
/**
*
* Specifies the desired time of departure. Uses the given time to calculate the route matrix. You can't set both
* DepartureTime
and DepartNow
. If neither is set, the best time of day to travel with the
* best traffic conditions is used to calculate the route matrix.
*
*
*
* Setting a departure time in the past returns a 400 ValidationException
error.
*
*
*
* -
*
* In ISO 8601 format:
* YYYY-MM-DDThh:mm:ss.sssZ
. For example, 2020–07-2T12:15:20.000Z+01:00
*
*
*
*
* @return Specifies the desired time of departure. Uses the given time to calculate the route matrix. You can't set
* both DepartureTime
and DepartNow
. If neither is set, the best time of day to
* travel with the best traffic conditions is used to calculate the route matrix.
*
* Setting a departure time in the past returns a 400 ValidationException
error.
*
*
*
* -
*
* In ISO 8601 format:
* YYYY-MM-DDThh:mm:ss.sssZ
. For example, 2020–07-2T12:15:20.000Z+01:00
*
*
*/
public final Instant departureTime() {
return departureTime;
}
/**
*
* Sets the time of departure as the current time. Uses the current time to calculate the route matrix. You can't
* set both DepartureTime
and DepartNow
. If neither is set, the best time of day to travel
* with the best traffic conditions is used to calculate the route matrix.
*
*
* Default Value: false
*
*
* Valid Values: false
| true
*
*
* @return Sets the time of departure as the current time. Uses the current time to calculate the route matrix. You
* can't set both DepartureTime
and DepartNow
. If neither is set, the best time of
* day to travel with the best traffic conditions is used to calculate the route matrix.
*
* Default Value: false
*
*
* Valid Values: false
| true
*/
public final Boolean departNow() {
return departNow;
}
/**
*
* Set the unit system to specify the distance.
*
*
* Default Value: Kilometers
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #distanceUnit} will
* return {@link DistanceUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #distanceUnitAsString}.
*
*
* @return Set the unit system to specify the distance.
*
* Default Value: Kilometers
* @see DistanceUnit
*/
public final DistanceUnit distanceUnit() {
return DistanceUnit.fromValue(distanceUnit);
}
/**
*
* Set the unit system to specify the distance.
*
*
* Default Value: Kilometers
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #distanceUnit} will
* return {@link DistanceUnit#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #distanceUnitAsString}.
*
*
* @return Set the unit system to specify the distance.
*
* Default Value: Kilometers
* @see DistanceUnit
*/
public final String distanceUnitAsString() {
return distanceUnit;
}
/**
*
* Specifies route preferences when traveling by Car
, such as avoiding routes that use ferries or
* tolls.
*
*
* Requirements: TravelMode
must be specified as Car
.
*
*
* @return Specifies route preferences when traveling by Car
, such as avoiding routes that use ferries
* or tolls.
*
* Requirements: TravelMode
must be specified as Car
.
*/
public final CalculateRouteCarModeOptions carModeOptions() {
return carModeOptions;
}
/**
*
* Specifies route preferences when traveling by Truck
, such as avoiding routes that use ferries or
* tolls, and truck specifications to consider when choosing an optimal road.
*
*
* Requirements: TravelMode
must be specified as Truck
.
*
*
* @return Specifies route preferences when traveling by Truck
, such as avoiding routes that use
* ferries or tolls, and truck specifications to consider when choosing an optimal road.
*
* Requirements: TravelMode
must be specified as Truck
.
*/
public final CalculateRouteTruckModeOptions truckModeOptions() {
return truckModeOptions;
}
/**
*
* The optional API key
* to authorize the request.
*
*
* @return The optional API
* key to authorize the request.
*/
public final String key() {
return key;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(calculatorName());
hashCode = 31 * hashCode + Objects.hashCode(hasDeparturePositions() ? departurePositions() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasDestinationPositions() ? destinationPositions() : null);
hashCode = 31 * hashCode + Objects.hashCode(travelModeAsString());
hashCode = 31 * hashCode + Objects.hashCode(departureTime());
hashCode = 31 * hashCode + Objects.hashCode(departNow());
hashCode = 31 * hashCode + Objects.hashCode(distanceUnitAsString());
hashCode = 31 * hashCode + Objects.hashCode(carModeOptions());
hashCode = 31 * hashCode + Objects.hashCode(truckModeOptions());
hashCode = 31 * hashCode + Objects.hashCode(key());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CalculateRouteMatrixRequest)) {
return false;
}
CalculateRouteMatrixRequest other = (CalculateRouteMatrixRequest) obj;
return Objects.equals(calculatorName(), other.calculatorName())
&& hasDeparturePositions() == other.hasDeparturePositions()
&& Objects.equals(departurePositions(), other.departurePositions())
&& hasDestinationPositions() == other.hasDestinationPositions()
&& Objects.equals(destinationPositions(), other.destinationPositions())
&& Objects.equals(travelModeAsString(), other.travelModeAsString())
&& Objects.equals(departureTime(), other.departureTime()) && Objects.equals(departNow(), other.departNow())
&& Objects.equals(distanceUnitAsString(), other.distanceUnitAsString())
&& Objects.equals(carModeOptions(), other.carModeOptions())
&& Objects.equals(truckModeOptions(), other.truckModeOptions()) && Objects.equals(key(), other.key());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("CalculateRouteMatrixRequest").add("CalculatorName", calculatorName())
.add("DeparturePositions", departurePositions() == null ? null : "*** Sensitive Data Redacted ***")
.add("DestinationPositions", destinationPositions() == null ? null : "*** Sensitive Data Redacted ***")
.add("TravelMode", travelModeAsString()).add("DepartureTime", departureTime()).add("DepartNow", departNow())
.add("DistanceUnit", distanceUnitAsString()).add("CarModeOptions", carModeOptions())
.add("TruckModeOptions", truckModeOptions()).add("Key", key() == null ? null : "*** Sensitive Data Redacted ***")
.build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "CalculatorName":
return Optional.ofNullable(clazz.cast(calculatorName()));
case "DeparturePositions":
return Optional.ofNullable(clazz.cast(departurePositions()));
case "DestinationPositions":
return Optional.ofNullable(clazz.cast(destinationPositions()));
case "TravelMode":
return Optional.ofNullable(clazz.cast(travelModeAsString()));
case "DepartureTime":
return Optional.ofNullable(clazz.cast(departureTime()));
case "DepartNow":
return Optional.ofNullable(clazz.cast(departNow()));
case "DistanceUnit":
return Optional.ofNullable(clazz.cast(distanceUnitAsString()));
case "CarModeOptions":
return Optional.ofNullable(clazz.cast(carModeOptions()));
case "TruckModeOptions":
return Optional.ofNullable(clazz.cast(truckModeOptions()));
case "Key":
return Optional.ofNullable(clazz.cast(key()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function