fix null NPE catch
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
index aaaac3b..7cd8099 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
@@ -10,6 +10,8 @@
}
public abstract IPVersion getIpVersion();
+
+ public abstract boolean contains(IPAddress<?> ip);
public F getSubnetBroadcastAddress() {
if (!mask.isCidrMask()) {
@@ -50,23 +52,4 @@
return res.toString();
}
-
- public boolean contains(IPAddress<?> ip) {
- Preconditions.checkNotNull(ip, "ip must not be null");
-
- // Ensure mask and IP of the same version
- if(getIpVersion() == ip.getIpVersion()) {
- if(getIpVersion() == IPVersion.IPv4) {
- IPv4AddressWithMask ipv4mask = (IPv4AddressWithMask) this;
- IPv4Address ipv4 = (IPv4Address) ip;
- return ipv4mask.matches(ipv4);
- } else {
- IPv6AddressWithMask ipv6mask = (IPv6AddressWithMask) this;
- IPv6Address ipv6 = (IPv6Address) ip;
- return ipv6mask.matches(ipv6);
- }
- }
- return false;
- }
-
}
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 9b60c6a..3d14acf 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
@@ -80,5 +80,14 @@
return IPv4AddressWithMask.of(ipv4, IPv4Address.of(mask));
}
}
-
+
+ @Override
+ public boolean contains(IPAddress<?> ip) {
+ if (ip == null) {
+ throw new NullPointerException("ip must not be null");
+ }
+
+ IPv4Address ipv4 = (IPv4Address) ip;
+ return this.matches(ipv4);
+ }
}
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
index 7259c7f..2e7ff5e 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
@@ -88,5 +88,14 @@
}
}
+ @Override
+ public boolean contains(IPAddress<?> ip) {
+ if (string == null) {
+ throw new NullPointerException("String must not be null");
+ }
+
+ IPv6Address ipv6 = (IPv6Address) ip;
+ return this.matches(ipv6);
+ }
}
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
index 2f59797..cbab734 100644
--- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
+++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
@@ -94,7 +94,8 @@
assertFalse(mask.contains(invalidIpv4));
}
- @Test public void testContainsException() {
+ @Test
+ public void testContainsException() {
try {
IPAddressWithMask<?> mask = IPAddressWithMask.of("1.2.3.4/24");
mask.contains(null);