All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.graph_builder.module.geometry.ShapeSegmentKey Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version


/**
 * 
 */
package org.opentripplanner.graph_builder.module.geometry;

import org.opentripplanner.model.FeedScopedId;

class ShapeSegmentKey {
    private FeedScopedId shapeId;

    private double shapeDistanceFrom;

    private double shapeDistanceTo;

    public ShapeSegmentKey(FeedScopedId shapeId, double shapeDistanceFrom, double shapeDistanceTo) {
        this.shapeId = shapeId;
        this.shapeDistanceFrom = shapeDistanceFrom;
        this.shapeDistanceTo = shapeDistanceTo;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        long temp;
        temp = Double.doubleToLongBits(shapeDistanceFrom);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(shapeDistanceTo);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        result = prime * result + ((shapeId == null) ? 0 : shapeId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ShapeSegmentKey other = (ShapeSegmentKey) obj;
        if (Double.doubleToLongBits(shapeDistanceFrom) != Double
                .doubleToLongBits(other.shapeDistanceFrom))
            return false;
        if (Double.doubleToLongBits(shapeDistanceTo) != Double
                .doubleToLongBits(other.shapeDistanceTo))
            return false;
        if (shapeId == null) {
            if (other.shapeId != null)
                return false;
        } else if (!shapeId.equals(other.shapeId))
            return false;
        return true;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy