Route CLI improvements and bug fixes
Change-Id: I4b4547f578cc053dc150066dadb68b6b2cbb82ee
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/routing/Route.java b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/Route.java
index c1cccc3..0ae4952 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/routing/Route.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/Route.java
@@ -21,6 +21,7 @@
import java.util.Objects;
+import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -70,7 +71,8 @@
*/
public Route(Source source, IpPrefix prefix, IpAddress nextHop) {
checkNotNull(prefix);
- checkArgument(nextHop == null || prefix.version().equals(nextHop.version()), VERSION_MISMATCH);
+ checkNotNull(nextHop);
+ checkArgument(prefix.version().equals(nextHop.version()), VERSION_MISMATCH);
this.source = checkNotNull(source);
this.prefix = prefix;
@@ -124,4 +126,12 @@
return Objects.equals(this.prefix, that.prefix) &&
Objects.equals(this.nextHop, that.nextHop);
}
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("prefix", prefix)
+ .add("nextHop", nextHop)
+ .toString();
+ }
}