Make ByteBuffer wrapped ID available.
We often need ByteBuffer wrapped byte[] to use as a Map key.
So expose ByteBuffer used to build ID.
Change-Id: Ic4b73a779faacf262b44735d21111b279ac2467e
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/SwitchEvent.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/SwitchEvent.java
index ea5b66d..0a25c47 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/SwitchEvent.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/SwitchEvent.java
@@ -35,15 +35,18 @@
public static final int SWITCHID_BYTES = 2 + 8;
- public static byte[] getSwitchID(Long dpid) {
+ public static ByteBuffer getSwitchID(Long dpid) {
if (dpid == null) {
throw new IllegalArgumentException("dpid cannot be null");
}
- return ByteBuffer.allocate(SwitchEvent.SWITCHID_BYTES).putChar('S').putLong(dpid)
- .array();
+ return ByteBuffer.allocate(SwitchEvent.SWITCHID_BYTES).putChar('S').putLong(dpid);
}
public byte[] getID() {
+ return getSwitchID(dpid).array();
+ }
+
+ public ByteBuffer getIDasByteBuffer() {
return getSwitchID(dpid);
}
}