Leftover follow-up commit for "1c8f47754241fea8b9c1463c08539ec31638a5de":
* Use the "@JsonProperty()" annotation to serialize/deserialize
objects that don't require any specialized processing.
Use "@JsonSerialize" and "@JsonDeserialize" only for objects
that need more specialized processing.
* Remove FooSerializer JSON classes that are not used/needed anymore.
* Update the implementation of remaining FooSerializer classes,
and associated Foo classes.
diff --git a/src/main/java/net/floodlightcontroller/util/IPv6Net.java b/src/main/java/net/floodlightcontroller/util/IPv6Net.java
index 1942293..b6f7d67 100644
--- a/src/main/java/net/floodlightcontroller/util/IPv6Net.java
+++ b/src/main/java/net/floodlightcontroller/util/IPv6Net.java
@@ -1,14 +1,17 @@
package net.floodlightcontroller.util;
import net.floodlightcontroller.util.IPv6;
+import net.floodlightcontroller.util.serializers.IPv6NetDeserializer;
import net.floodlightcontroller.util.serializers.IPv6NetSerializer;
import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* The class representing an IPv6 network address.
*/
+@JsonDeserialize(using=IPv6NetDeserializer.class)
@JsonSerialize(using=IPv6NetSerializer.class)
public class IPv6Net {
private IPv6 address; // The IPv6 address
@@ -33,6 +36,21 @@
}
/**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public IPv6Net(String value) {
+ String[] splits = value.split("/");
+ if (splits.length != 2) {
+ throw new IllegalArgumentException("Specified IPv6Net address must contain an IPv6 " +
+ "address and a prefix length separated by '/'");
+ }
+ this.address = new IPv6(splits[0]);
+ this.prefixLen = Short.decode(splits[1]);
+ }
+
+ /**
* Get the address value of the IPv6Net address.
*
* @return the address value of the IPv6Net address.
@@ -40,6 +58,15 @@
public IPv6 address() { return address; }
/**
+ * 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.
@@ -47,6 +74,15 @@
public short prefixLen() { return prefixLen; }
/**
+ * 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.