Add FlowIdGenerator's implementation class.
- Updated FlowId to use long internally
- Implemented FlowIdGeneratorWithIdBlockAllocator class as an implementation class of FlowIdGenerator.
Change-Id: Id3bcb47c63217b0ea4a2f7d5ae208532783c323a
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java b/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
index 9d1f0ed..f6d7f8a 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
@@ -1,37 +1,41 @@
package net.onrc.onos.api.flowmanager;
+import java.util.Objects;
+
import net.onrc.onos.api.batchoperation.BatchOperationTarget;
/**
* Represents ID for Flow objects.
*/
public class FlowId implements BatchOperationTarget {
- private final String value;
+ private final long value;
/**
* Creates new instance with string ID.
+ * <p>
+ * This FlowId instance should be generated with {@link FlowIdGenerator}.
*
* @param id String representation of the ID.
*/
- public FlowId(String id) {
+ public FlowId(long id) {
value = id;
}
@Override
public String toString() {
- return value;
+ return Long.toString(value);
}
@Override
public int hashCode() {
- return value.hashCode();
+ return Objects.hashCode(value);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof FlowId) {
- FlowId other = (FlowId) obj;
- return (this.value.equals(other.value));
+ FlowId that = (FlowId) obj;
+ return Objects.equals(this.value, that.value);
}
return false;
}