Updated toString methods
* Added toString() in DefaultDeviceInterfaceDescription
* Updated toString() in DefaultTableStatisticsEntry
* Removed unecessary space in DeviceSystemStatisticsQuery
Change-Id: Ib4536d3f10d6c9e2e4805887186e57f5ab321fd8
Signed-off-by: Georgios Katsikas <katsikas.gp@gmail.com>
diff --git a/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceInterfaceDescription.java b/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceInterfaceDescription.java
index f3b38c9..7e5f8e6 100644
--- a/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceInterfaceDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/device/DefaultDeviceInterfaceDescription.java
@@ -22,6 +22,8 @@
import java.util.List;
import java.util.Objects;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
/**
* Basic implementation of description of a legacy device interface.
*/
@@ -127,4 +129,17 @@
public int hashCode() {
return Objects.hash(name, mode, vlans, isRateLimited, rateLimit);
}
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("Device name", name())
+ .add("Device mode", mode())
+ .add("VLAN IDs", vlans())
+ .add("Rate limited", isRateLimited())
+ .add("Rate limit", rateLimit())
+ .toString();
+ }
+
}
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTableStatisticsEntry.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTableStatisticsEntry.java
index e84b343..ccce84e 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTableStatisticsEntry.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTableStatisticsEntry.java
@@ -16,6 +16,8 @@
package org.onosproject.net.flow;
import org.onosproject.net.DeviceId;
+import com.google.common.base.MoreObjects.ToStringHelper;
+import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -57,11 +59,21 @@
@Override
public String toString() {
- return "device: " + deviceId + ", " +
- "tableId: " + this.tableId + ", " +
- "activeEntries: " + this.activeFlowEntries + ", " +
- "packetsLookedUp: " + this.packetsLookedupCount + ", " +
- "packetsMatched: " + this.packetsMatchedCount;
+ ToStringHelper toStringHelper = toStringHelper(this);
+ toStringHelper
+ .omitNullValues()
+ .add("Device ID", deviceId)
+ .add("Table ID", tableId)
+ .add("Active entries", activeFlowEntries);
+ if (hasPacketsLookedup()) {
+ toStringHelper.add("Packets looked-up", packetsLookedupCount);
+ }
+ toStringHelper.add("Packets matched", packetsMatchedCount);
+ if (hasMaxSize()) {
+ toStringHelper.add("Max size", maxSize);
+ }
+
+ return toStringHelper.toString();
}
@Override
@@ -163,4 +175,4 @@
}
}
-}
\ No newline at end of file
+}