001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.gpx;
003
004import java.util.Collection;
005import java.util.LinkedList;
006
007/**
008 * A route is a part of a GPX file containing of multiple GPX points.
009 */
010public class GpxRoute extends WithAttributes {
011    /**
012     * The points this route consists of. Should not be changed after creation.
013     * <p>
014     * This collection is ordered.
015     */
016    public Collection<WayPoint> routePoints = new LinkedList<>();
017
018    @Override
019    public int hashCode() {
020        return 31 * super.hashCode() + ((routePoints == null) ? 0 : routePoints.hashCode());
021    }
022
023    @Override
024    public boolean equals(Object obj) {
025        if (this == obj)
026            return true;
027        if (!super.equals(obj))
028            return false;
029        if (getClass() != obj.getClass())
030            return false;
031        GpxRoute other = (GpxRoute) obj;
032        if (routePoints == null) {
033            if (other.routePoints != null)
034                return false;
035        } else if (!routePoints.equals(other.routePoints))
036            return false;
037        return true;
038    }
039}