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/IPv6Net.java b/src/main/java/net/onrc/onos/core/util/IPv6Net.java
index 1faa7c5..72ec5e9 100644
--- a/src/main/java/net/onrc/onos/core/util/IPv6Net.java
+++ b/src/main/java/net/onrc/onos/core/util/IPv6Net.java
@@ -8,17 +8,19 @@
/**
* The class representing an IPv6 network address.
+ * This class is immutable.
*/
@JsonDeserialize(using = IPv6NetDeserializer.class)
@JsonSerialize(using = IPv6NetSerializer.class)
-public class IPv6Net {
- private IPv6 address; // The IPv6 address
- private short prefixLen; // The prefix length
+public final class IPv6Net {
+ private final IPv6 address; // The IPv6 address
+ private final short prefixLen; // The prefix length
/**
* Default constructor.
*/
public IPv6Net() {
+ this.address = null;
this.prefixLen = 0;
}
@@ -30,6 +32,8 @@
public IPv6Net(IPv6Net other) {
if (other.address != null)
this.address = new IPv6(other.address);
+ else
+ this.address = null;
this.prefixLen = other.prefixLen;
}
@@ -69,15 +73,6 @@
}
/**
- * Set the address value of the IPv6Net address.
- *
- * @param address the address to use.
- */
- public void setAddress(IPv6 address) {
- this.address = address;
- }
-
- /**
* Get the prefix length value of the IPv6Net address.
*
* @return the prefix length value of the IPv6Net address.
@@ -87,26 +82,6 @@
}
/**
- * Set the prefix length value of the IPv6Net address.
- *
- * @param prefixLen the prefix length to use.
- */
- public void setPrefixLen(short prefixLen) {
- this.prefixLen = prefixLen;
- }
-
- /**
- * Set the value of the IPv6Net address.
- *
- * @param address the address to use.
- * @param prefixLen the prefix length to use.
- */
- public void setValue(IPv6 address, short prefixLen) {
- this.address = address;
- this.prefixLen = prefixLen;
- }
-
- /**
* Convert the IPv6Net value to an "address/prefixLen" string.
*
* @return the IPv6Net value as an "address/prefixLen" string.