diff --git a/src/main/java/it/unibz/inf/isochrone/network/Link.java b/src/main/java/it/unibz/inf/isochrone/network/Link.java index 799fe594926c8cd5b7a14814d02aaae39488a96f..c08c583eab4ae9e828048401b7fdfb7ff9bf6a00 100644 --- a/src/main/java/it/unibz/inf/isochrone/network/Link.java +++ b/src/main/java/it/unibz/inf/isochrone/network/Link.java @@ -50,46 +50,70 @@ public class Link { continuous = false; } - public int getID() { - return id; + // Getter + + public int getEndNode() { + return endNode; } - public int getStartNode() { - return startNode; + public double getEndOffset() { + return endOffset; } - public int getEndNode() { - return endNode; + public int getId() { + return id; } public double getLength() { return length; } + /** + * Returns the "opposite" node of the current Link object. + * + * @param node relative Node reference + * @return opposite Node of this link (or null) + */ + public int getOppositeOf(final Node node) { + if (getStartNode() == node.getId()) { + return endNode; + } + + return startNode; + } + + public int getRoute() { + if (!continuous) { + return route; + } + + throw new RuntimeException("There is no route for a continuous link"); + } + + public int getStartNode() { + return startNode; + } + public double getStartOffset() { return startOffset; } - public double getEndOffset() { - return endOffset; + public boolean isContinuous() { + return continuous; } - public void setStartOffset(final double startOffset) { - this.startOffset = startOffset; - } + // Setter public void setEndOffset(final double endOffset) { this.endOffset = endOffset; } - public int getRoute() { - if (!continuous) { - return route; - } - - throw new RuntimeException("There is no route for a continuous link"); + public void setStartOffset(final double startOffset) { + this.startOffset = startOffset; } + // Public methods + @Override public boolean equals(final Object object) { if (!(object instanceof Link)) { @@ -97,7 +121,7 @@ public class Link { } final Link l = (Link) object; - if (getID() != l.getID() + if (getId() != l.getId() || getStartNode() != l.getStartNode() || getEndNode() != l.getEndNode() || isContinuous() != l.isContinuous()) { @@ -134,22 +158,9 @@ public class Link { return result; } - public boolean isContinuous() { - return continuous; - } - - /** - * Returns the "opposite" node of the current Link object. - * - * @param node relative Node reference - * @return opposite Node of this link (or null) - */ - public int getOppositeOf(final Node node) { - if (getStartNode() == node.getId()) { - return endNode; - } - - return startNode; + @Override + public String toString() { + return "Link [id=" + id + ", continuous=" + continuous + ", length=" + length + "]"; } }