diff options
Diffstat (limited to 'base/src/main/java/bjc/utils/graph/Edge.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/graph/Edge.java | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/base/src/main/java/bjc/utils/graph/Edge.java b/base/src/main/java/bjc/utils/graph/Edge.java index e7e7b36..fe3d891 100644 --- a/base/src/main/java/bjc/utils/graph/Edge.java +++ b/base/src/main/java/bjc/utils/graph/Edge.java @@ -6,7 +6,7 @@ package bjc.utils.graph; * @author ben * * @param <T> - * The type of the nodes in the graph. + * The type of the nodes in the graph. */ public class Edge<T> { /* The distance from initial to terminal node. */ @@ -19,18 +19,18 @@ public class Edge<T> { * Create a new edge with set parameters. * * @param initial - * The initial node of the edge. + * The initial node of the edge. * * @param terminal - * The terminal node of the edge. + * The terminal node of the edge. * * @param distance - * The distance between initial and terminal edge. + * The distance between initial and terminal edge. */ public Edge(final T initial, final T terminal, final int distance) { - if(initial == null) { + if (initial == null) { throw new NullPointerException("Initial node must not be null"); - } else if(terminal == null) { + } else if (terminal == null) { throw new NullPointerException("Terminal node must not be null"); } @@ -41,24 +41,27 @@ public class Edge<T> { @Override public boolean equals(final Object obj) { - if(this == obj) + if (this == obj) return true; - else if(obj == null) + else if (obj == null) return false; - else if(getClass() != obj.getClass()) + else if (getClass() != obj.getClass()) return false; else { final Edge<?> other = (Edge<?>) obj; - if(distance != other.distance) + if (distance != other.distance) return false; - else if(source == null) { - if(other.source != null) return false; - } else if(!source.equals(other.source)) + else if (source == null) { + if (other.source != null) + return false; + } else if (!source.equals(other.source)) + return false; + else if (target == null) { + if (other.target != null) + return false; + } else if (!target.equals(other.target)) return false; - else if(target == null) { - if(other.target != null) return false; - } else if(!target.equals(other.target)) return false; return true; } @@ -67,8 +70,7 @@ public class Edge<T> { /** * Get the distance in this edge. * - * @return The distance between the initial and terminal nodes of this - * edge. + * @return The distance between the initial and terminal nodes of this edge. */ public int getDistance() { return distance; @@ -107,8 +109,9 @@ public class Edge<T> { @Override public String toString() { - String msg = String.format("source vertex %s to target vertex %s with distance: %s", source, target, - distance); + String msg + = String.format("source vertex %s to target vertex %s with distance: %s", + source, target, distance); return msg; } |
