/* * Copyright 2010-2023 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 com.amazonaws.services.geo.model; import java.io.Serializable; /** *

* Contains the calculated route's details for each path between a pair of * positions. The number of legs returned corresponds to one fewer than the * total number of positions in the request. *

*

* For example, a route with a departure position and destination position * returns one leg with the positions snapped to a nearby road: *

* *

* A route with a waypoint between the departure and destination position * returns two legs with the positions snapped to a nearby road: *

* */ public class Leg implements Serializable { /** *

* The distance between the leg's StartPosition and * EndPosition along a calculated route. *

* *

* Constraints:
* Range: 0.0 -
*/ private Double distance; /** *

* The estimated travel time between the leg's StartPosition * and EndPosition. The travel mode and departure time that you * specify in the request determines the calculated time. *

*

* Constraints:
* Range: 0.0 -
*/ private Double durationSeconds; /** *

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's snapped to a nearby road. *

*
*/ private java.util.List endPosition; /** *

* Contains the calculated route's path as a linestring geometry. *

*/ private LegGeometry geometry; /** *

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, it's snapped to a nearby road. *

*
*/ private java.util.List startPosition; /** *

* Contains a list of steps, which represent subsections of a leg. Each step * provides instructions for how to move to the next step in the leg such as * the step's start position, end position, travel distance, travel * duration, and geometry offset. *

*/ private java.util.List steps; /** *

* The distance between the leg's StartPosition and * EndPosition along a calculated route. *

*
    *
  • *

    * The default measurement is Kilometers unless the request * specifies a DistanceUnit of Miles. *

    *
  • *
*

* Constraints:
* Range: 0.0 -
* * @return

* The distance between the leg's StartPosition and * EndPosition along a calculated route. *

*
    *
  • *

    * The default measurement is Kilometers unless the * request specifies a DistanceUnit of * Miles. *

    *
  • *
*/ public Double getDistance() { return distance; } /** *

* The distance between the leg's StartPosition and * EndPosition along a calculated route. *

*
    *
  • *

    * The default measurement is Kilometers unless the request * specifies a DistanceUnit of Miles. *

    *
  • *
*

* Constraints:
* Range: 0.0 -
* * @param distance

* The distance between the leg's StartPosition and * EndPosition along a calculated route. *

*
    *
  • *

    * The default measurement is Kilometers unless the * request specifies a DistanceUnit of * Miles. *

    *
  • *
*/ public void setDistance(Double distance) { this.distance = distance; } /** *

* The distance between the leg's StartPosition and * EndPosition along a calculated route. *

*
    *
  • *

    * The default measurement is Kilometers unless the request * specifies a DistanceUnit of Miles. *

    *
  • *
*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Range: 0.0 -
* * @param distance

* The distance between the leg's StartPosition and * EndPosition along a calculated route. *

*
    *
  • *

    * The default measurement is Kilometers unless the * request specifies a DistanceUnit of * Miles. *

    *
  • *
* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withDistance(Double distance) { this.distance = distance; return this; } /** *

* The estimated travel time between the leg's StartPosition * and EndPosition. The travel mode and departure time that you * specify in the request determines the calculated time. *

*

* Constraints:
* Range: 0.0 -
* * @return

* The estimated travel time between the leg's * StartPosition and EndPosition. The * travel mode and departure time that you specify in the request * determines the calculated time. *

*/ public Double getDurationSeconds() { return durationSeconds; } /** *

* The estimated travel time between the leg's StartPosition * and EndPosition. The travel mode and departure time that you * specify in the request determines the calculated time. *

*

* Constraints:
* Range: 0.0 -
* * @param durationSeconds

* The estimated travel time between the leg's * StartPosition and EndPosition. The * travel mode and departure time that you specify in the request * determines the calculated time. *

*/ public void setDurationSeconds(Double durationSeconds) { this.durationSeconds = durationSeconds; } /** *

* The estimated travel time between the leg's StartPosition * and EndPosition. The travel mode and departure time that you * specify in the request determines the calculated time. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Range: 0.0 -
* * @param durationSeconds

* The estimated travel time between the leg's * StartPosition and EndPosition. The * travel mode and departure time that you specify in the request * determines the calculated time. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withDurationSeconds(Double durationSeconds) { this.durationSeconds = durationSeconds; return this; } /** *

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's snapped to a nearby road. *

*
* * @return

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's snapped to a nearby road. *

*
*/ public java.util.List getEndPosition() { return endPosition; } /** *

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's snapped to a nearby road. *

*
* * @param endPosition

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's * snapped to a nearby road. *

*
*/ public void setEndPosition(java.util.Collection endPosition) { if (endPosition == null) { this.endPosition = null; return; } this.endPosition = new java.util.ArrayList(endPosition); } /** *

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's snapped to a nearby road. *

*
*

* Returns a reference to this object so that method calls can be chained * together. * * @param endPosition

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's * snapped to a nearby road. *

*
* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withEndPosition(Double... endPosition) { if (getEndPosition() == null) { this.endPosition = new java.util.ArrayList(endPosition.length); } for (Double value : endPosition) { this.endPosition.add(value); } return this; } /** *

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's snapped to a nearby road. *

*
*

* Returns a reference to this object so that method calls can be chained * together. * * @param endPosition

* The terminating position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the EndPosition isn't located on a road, it's * snapped to a nearby road. *

*
* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withEndPosition(java.util.Collection endPosition) { setEndPosition(endPosition); return this; } /** *

* Contains the calculated route's path as a linestring geometry. *

* * @return

* Contains the calculated route's path as a linestring geometry. *

*/ public LegGeometry getGeometry() { return geometry; } /** *

* Contains the calculated route's path as a linestring geometry. *

* * @param geometry

* Contains the calculated route's path as a linestring geometry. *

*/ public void setGeometry(LegGeometry geometry) { this.geometry = geometry; } /** *

* Contains the calculated route's path as a linestring geometry. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param geometry

* Contains the calculated route's path as a linestring geometry. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withGeometry(LegGeometry geometry) { this.geometry = geometry; return this; } /** *

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, it's snapped to a nearby road. *

*
* * @return

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, it's * snapped to a nearby road. *

*
*/ public java.util.List getStartPosition() { return startPosition; } /** *

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, it's snapped to a nearby road. *

*
* * @param startPosition

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, * it's snapped to a nearby road. *

*
*/ public void setStartPosition(java.util.Collection startPosition) { if (startPosition == null) { this.startPosition = null; return; } this.startPosition = new java.util.ArrayList(startPosition); } /** *

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, it's snapped to a nearby road. *

*
*

* Returns a reference to this object so that method calls can be chained * together. * * @param startPosition

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, * it's snapped to a nearby road. *

*
* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withStartPosition(Double... startPosition) { if (getStartPosition() == null) { this.startPosition = new java.util.ArrayList(startPosition.length); } for (Double value : startPosition) { this.startPosition.add(value); } return this; } /** *

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, it's snapped to a nearby road. *

*
*

* Returns a reference to this object so that method calls can be chained * together. * * @param startPosition

* The starting position of the leg. Follows the format * [longitude,latitude]. *

* *

* If the StartPosition isn't located on a road, * it's snapped to a nearby road. *

*
* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withStartPosition(java.util.Collection startPosition) { setStartPosition(startPosition); return this; } /** *

* Contains a list of steps, which represent subsections of a leg. Each step * provides instructions for how to move to the next step in the leg such as * the step's start position, end position, travel distance, travel * duration, and geometry offset. *

* * @return

* Contains a list of steps, which represent subsections of a leg. * Each step provides instructions for how to move to the next step * in the leg such as the step's start position, end position, * travel distance, travel duration, and geometry offset. *

*/ public java.util.List getSteps() { return steps; } /** *

* Contains a list of steps, which represent subsections of a leg. Each step * provides instructions for how to move to the next step in the leg such as * the step's start position, end position, travel distance, travel * duration, and geometry offset. *

* * @param steps

* Contains a list of steps, which represent subsections of a * leg. Each step provides instructions for how to move to the * next step in the leg such as the step's start position, end * position, travel distance, travel duration, and geometry * offset. *

*/ public void setSteps(java.util.Collection steps) { if (steps == null) { this.steps = null; return; } this.steps = new java.util.ArrayList(steps); } /** *

* Contains a list of steps, which represent subsections of a leg. Each step * provides instructions for how to move to the next step in the leg such as * the step's start position, end position, travel distance, travel * duration, and geometry offset. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param steps

* Contains a list of steps, which represent subsections of a * leg. Each step provides instructions for how to move to the * next step in the leg such as the step's start position, end * position, travel distance, travel duration, and geometry * offset. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withSteps(Step... steps) { if (getSteps() == null) { this.steps = new java.util.ArrayList(steps.length); } for (Step value : steps) { this.steps.add(value); } return this; } /** *

* Contains a list of steps, which represent subsections of a leg. Each step * provides instructions for how to move to the next step in the leg such as * the step's start position, end position, travel distance, travel * duration, and geometry offset. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param steps

* Contains a list of steps, which represent subsections of a * leg. Each step provides instructions for how to move to the * next step in the leg such as the step's start position, end * position, travel distance, travel duration, and geometry * offset. *

* @return A reference to this updated object so that method calls can be * chained together. */ public Leg withSteps(java.util.Collection steps) { setSteps(steps); return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getDistance() != null) sb.append("Distance: " + getDistance() + ","); if (getDurationSeconds() != null) sb.append("DurationSeconds: " + getDurationSeconds() + ","); if (getEndPosition() != null) sb.append("EndPosition: " + getEndPosition() + ","); if (getGeometry() != null) sb.append("Geometry: " + getGeometry() + ","); if (getStartPosition() != null) sb.append("StartPosition: " + getStartPosition() + ","); if (getSteps() != null) sb.append("Steps: " + getSteps()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDistance() == null) ? 0 : getDistance().hashCode()); hashCode = prime * hashCode + ((getDurationSeconds() == null) ? 0 : getDurationSeconds().hashCode()); hashCode = prime * hashCode + ((getEndPosition() == null) ? 0 : getEndPosition().hashCode()); hashCode = prime * hashCode + ((getGeometry() == null) ? 0 : getGeometry().hashCode()); hashCode = prime * hashCode + ((getStartPosition() == null) ? 0 : getStartPosition().hashCode()); hashCode = prime * hashCode + ((getSteps() == null) ? 0 : getSteps().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Leg == false) return false; Leg other = (Leg) obj; if (other.getDistance() == null ^ this.getDistance() == null) return false; if (other.getDistance() != null && other.getDistance().equals(this.getDistance()) == false) return false; if (other.getDurationSeconds() == null ^ this.getDurationSeconds() == null) return false; if (other.getDurationSeconds() != null && other.getDurationSeconds().equals(this.getDurationSeconds()) == false) return false; if (other.getEndPosition() == null ^ this.getEndPosition() == null) return false; if (other.getEndPosition() != null && other.getEndPosition().equals(this.getEndPosition()) == false) return false; if (other.getGeometry() == null ^ this.getGeometry() == null) return false; if (other.getGeometry() != null && other.getGeometry().equals(this.getGeometry()) == false) return false; if (other.getStartPosition() == null ^ this.getStartPosition() == null) return false; if (other.getStartPosition() != null && other.getStartPosition().equals(this.getStartPosition()) == false) return false; if (other.getSteps() == null ^ this.getSteps() == null) return false; if (other.getSteps() != null && other.getSteps().equals(this.getSteps()) == false) return false; return true; } }