Address reviewer's comments floodlight/loxigen#297
Reference:
https://github.com/floodlight/loxigen/pull/297
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
index 78c568f..4cb0fa5 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
@@ -61,6 +61,37 @@
public abstract F not();
/**
+ * Returns an {@code IPAddressWithMask<F>} object that represents this
+ * IP address masked by the given IP address mask.
+ *
+ * @param mask the {@code F} object that represents the mask
+ * @return an {@code IPAddressWithMask<F>} object that represents this
+ * IP address masked by the given mask
+ * @throws NullPointerException if the given mask was {@code null}
+ */
+ @Nonnull
+ public abstract IPAddressWithMask<F> withMask(@Nonnull final F mask);
+
+ /**
+ * Returns an {@code IPAddressWithMask<F>} object that represents this
+ * IP address masked by the CIDR subnet mask of the given prefix length.
+ *
+ * @param cidrMaskLength the prefix length of the CIDR subnet mask
+ * (i.e. the number of leading one-bits),
+ * where <code>
+ * 0 <= cidrMaskLength <= (F.getLength() * 8)
+ * </code>
+ * @return an {@code IPAddressWithMask<F>} object that
+ * represents this IP address masked by the CIDR
+ * subnet mask of the given prefix length
+ * @throws IllegalArgumentException if the given prefix length was invalid
+ * @see #ofCidrMaskLength(int)
+ */
+ @Nonnull
+ public abstract IPAddressWithMask<F> withMaskOfLength(
+ final int cidrMaskLength);
+
+ /**
* Returns the raw IP address of this {@code IPAddress} object. The result
* is in network byte order: the highest order byte of the address is in
* {@code getBytes()[0]}.
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
index 74cd7b0..3a1b15e 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
@@ -239,82 +239,13 @@
* @throws NullPointerException if the given mask was {@code null}
*/
@Nonnull
+ @Override
public IPv4AddressWithMask withMask(@Nonnull final IPv4Address mask) {
return IPv4AddressWithMask.of(this, mask);
}
/**
* Returns an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given IP address mask. The argument is in
- * network byte order: the highest order byte of the address is in
- * {@code mask[0]}.
- * <p>
- * The address byte array must be 4 bytes long (32 bits long).
- *
- * @param mask the raw IP address mask in network byte order
- * @return an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given raw IP address mask
- * @throws NullPointerException if the given mask was {@code null}
- * @throws IllegalArgumentException if the given mask was of an invalid
- * byte array length
- * @see #of(byte[])
- */
- @Nonnull
- public IPv4AddressWithMask withMask(@Nonnull final byte[] mask) {
- return IPv4AddressWithMask.of(this, IPv4Address.of(mask));
- }
-
- /**
- * Returns an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given IP address mask.
- *
- * @param mask the raw IP address mask represented as a 32-bit integer
- * @return an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given raw IP address mask
- * @see #of(int)
- */
- @Nonnull
- public IPv4AddressWithMask withMask(final int mask) {
- return IPv4AddressWithMask.of(this, IPv4Address.of(mask));
- }
-
- /**
- * Returns an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given IP address mask. The argument is in
- * the canonical quad-dotted notation. For example, {@code 255.255.255.0}.
- *
- * @param mask the IP address mask in the canonical quad-dotted notation
- * @return an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given IP address mask
- * @throws NullPointerException if the given string was {@code null}
- * @throws IllegalArgumentException if the given string was not a valid
- * IPv4 address
- * @see #of(String)
- */
- @Nonnull
- public IPv4AddressWithMask withMask(@Nonnull final String mask) {
- return IPv4AddressWithMask.of(this, IPv4Address.of(mask));
- }
-
- /**
- * Returns an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given IP address mask. The argument is given as
- * an {@code Inet4Address} object.
- *
- * @param mask the IP address mask as an {@code Inet4Address} object
- * @return an {@code IPv4AddressWithMask} object that represents this
- * IP address masked by the given IP address mask
- * @throws NullPointerException if the given {@code Inet4Address} was
- * {@code null}
- * @see #of(Inet4Address)
- */
- @Nonnull
- public IPv4AddressWithMask withMask(@Nonnull final Inet4Address mask) {
- return IPv4AddressWithMask.of(this, IPv4Address.of(mask));
- }
-
- /**
- * Returns an {@code IPv4AddressWithMask} object that represents this
* IP address masked by the CIDR subnet mask of the given prefix length.
*
* @param cidrMaskLength the prefix length of the CIDR subnet mask
@@ -327,9 +258,9 @@
* @see #ofCidrMaskLength(int)
*/
@Nonnull
+ @Override
public IPv4AddressWithMask withMaskOfLength(final int cidrMaskLength) {
- return IPv4AddressWithMask.of(this,
- IPv4Address.ofCidrMaskLength(cidrMaskLength));
+ return this.withMask(IPv4Address.ofCidrMaskLength(cidrMaskLength));
}
public int getInt() {
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
index 6bd5539..b6dc1b9 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
@@ -30,8 +30,10 @@
* @return an {@code IPv4AddressWithMask} object that represents
* the given raw IP address masked by the given raw IP
* address mask
- * @deprecated replaced by {@link IPv4Address#of(int)} followed by
- * {@link IPv4Address#withMask(int)}
+ * @deprecated replaced by {@link IPv4Address#of(int)} and
+ * {@link IPv4Address#withMask(IPv4Address), e.g. <code>
+ * IPv4Address.of(int).withMask(IPv4Address.of(int))
+ * </code>
*/
@Nonnull
@Deprecated
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
index 4b66a8d..dcbd4a1 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
@@ -342,6 +342,40 @@
}
}
+ /**
+ * Returns an {@code IPv6AddressWithMask} object that represents this
+ * IP address masked by the given IP address mask.
+ *
+ * @param mask the {@code IPv6Address} object that represents the mask
+ * @return an {@code IPv6AddressWithMask} object that represents this
+ * IP address masked by the given mask
+ * @throws NullPointerException if the given mask was {@code null}
+ */
+ @Nonnull
+ @Override
+ public IPv6AddressWithMask withMask(@Nonnull final IPv6Address mask) {
+ return IPv6AddressWithMask.of(this, mask);
+ }
+
+ /**
+ * Returns an {@code IPv6AddressWithMask} object that represents this
+ * IP address masked by the CIDR subnet mask of the given prefix length.
+ *
+ * @param cidrMaskLength the prefix length of the CIDR subnet mask
+ * (i.e. the number of leading one-bits),
+ * where {@code 0 <= cidrMaskLength <= 128}
+ * @return an {@code IPv6AddressWithMask} object that
+ * represents this IP address masked by the CIDR
+ * subnet mask of the given prefix length
+ * @throws IllegalArgumentException if the given prefix length was invalid
+ * @see #ofCidrMaskLength(int)
+ */
+ @Nonnull
+ @Override
+ public IPv6AddressWithMask withMaskOfLength(final int cidrMaskLength) {
+ return this.withMask(IPv6Address.ofCidrMaskLength(cidrMaskLength));
+ }
+
private volatile byte[] bytesCache = null;
public byte[] getBytes() {