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

rinde.sim.core.graph.LengthData Maven / Gradle / Ivy

There is a newer version: 4.4.6
Show newest version
package rinde.sim.core.graph;

/**
 * Simple implementation of {@link ConnectionData}, allowing to specify the
 * length of a connection.
 * @author Bartosz Michalik 
 * @author Rinde van Lon 
 */
public class LengthData implements ConnectionData {

    /**
     * Represents an empty value for usage in a {@link TableGraph}.
     */
    public static final LengthData EMPTY = new LengthData(Double.NaN);

    private final double length;

    /**
     * Instantiate a new instance using the specified length.
     * @param pLength The length of the connection.
     */
    public LengthData(double pLength) {
        length = pLength;
    }

    @Override
    public double getLength() {
        return length;
    }

    @Override
    public int hashCode() {
        return Double.valueOf(length).hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof LengthData) {
            return Double.compare(length, ((LengthData) obj).length) == 0;
        }
        return false;
    }

    @Override
    public String toString() {
        return length + "";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy