Add a exceptional port number to do not display port number
The PortNumber class always displays numeric value if it has name.
But in some case, we don't want to display numeric value.
This patch provide this behavior.
Change-Id: I3d91742594c4aef7eaa103190159605aed31e2a0
diff --git a/core/api/src/main/java/org/onosproject/net/PortNumber.java b/core/api/src/main/java/org/onosproject/net/PortNumber.java
index e10695f..9d1d7b7 100644
--- a/core/api/src/main/java/org/onosproject/net/PortNumber.java
+++ b/core/api/src/main/java/org/onosproject/net/PortNumber.java
@@ -49,6 +49,8 @@
static final long LOCAL_NUMBER = -2L;
static final long ANY_NUMBER = -1L;
+ public static final long NO_DISPLAY_NUMBER = -1L;
+
/**
* Logical PortNumbers.
*/
@@ -251,7 +253,11 @@
return decodeLogicalPort();
} else if (hasName()) {
// named port
- return String.format("[%s](%d)", name, number);
+ if (number == NO_DISPLAY_NUMBER) {
+ return String.format("[%s]", name);
+ } else {
+ return String.format("[%s](%d)", name, number);
+ }
} else {
// unsigned decimal string
return name;