Change some of the basic classes in the "unit/" directory to immutable:
* Change each class to "final"
* Change the fields to "final"
* Remove the "set" methods
Change-Id: I3499489024403b55328ffb1827fc8c3b5ffd231e
diff --git a/src/main/java/net/onrc/onos/core/util/FlowEntryId.java b/src/main/java/net/onrc/onos/core/util/FlowEntryId.java
index 373962e..62c009a 100644
--- a/src/main/java/net/onrc/onos/core/util/FlowEntryId.java
+++ b/src/main/java/net/onrc/onos/core/util/FlowEntryId.java
@@ -11,17 +11,19 @@
/**
* The class representing a Flow Entry ID.
+ * This class is immutable.
*/
@JsonDeserialize(using = FlowEntryIdDeserializer.class)
@JsonSerialize(using = FlowEntryIdSerializer.class)
-public class FlowEntryId {
- private long value;
+public final class FlowEntryId {
+ private final static long INVALID = -1;
+ private final long value;
/**
* Default constructor.
*/
public FlowEntryId() {
- this.value = -1;
+ this.value = FlowEntryId.INVALID;
}
/**
@@ -62,22 +64,13 @@
}
/**
- * Set the value of the Flow Entry ID.
- *
- * @param value the value to set.
- */
- public void setValue(long value) {
- this.value = value;
- }
-
- /**
* Test whether the Flow Entry ID is valid.
*
* @return true if the Flow Entry ID is valid, otherwise false.
*/
@JsonIgnore
public boolean isValid() {
- return (this.value() != -1);
+ return (this.value() != FlowEntryId.INVALID);
}
/**