Switch to checkNotNull
Change-Id: Ie34d783d5dcb0e6f71fd6155c14aaaaf47048bcc
diff --git a/src/main/java/net/onrc/onos/core/util/LinkTuple.java b/src/main/java/net/onrc/onos/core/util/LinkTuple.java
index 4e80826..7831925 100644
--- a/src/main/java/net/onrc/onos/core/util/LinkTuple.java
+++ b/src/main/java/net/onrc/onos/core/util/LinkTuple.java
@@ -1,8 +1,8 @@
package net.onrc.onos.core.util;
-import java.util.Objects;
+import static com.google.common.base.Preconditions.checkNotNull;
-import org.apache.commons.lang.Validate;
+import java.util.Objects;
/**
@@ -28,11 +28,8 @@
* @param dst destination port
*/
public LinkTuple(SwitchPort src, SwitchPort dst) {
- Validate.notNull(src);
- Validate.notNull(dst);
-
- this.src = src;
- this.dst = dst;
+ this.src = checkNotNull(src);
+ this.dst = checkNotNull(dst);
}
/**
diff --git a/src/main/java/net/onrc/onos/core/util/SwitchPort.java b/src/main/java/net/onrc/onos/core/util/SwitchPort.java
index e296b7b..74f0ed4 100644
--- a/src/main/java/net/onrc/onos/core/util/SwitchPort.java
+++ b/src/main/java/net/onrc/onos/core/util/SwitchPort.java
@@ -1,8 +1,9 @@
package net.onrc.onos.core.util;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import net.onrc.onos.core.util.serializers.SwitchPortSerializer;
-import org.apache.commons.lang.Validate;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
@@ -29,10 +30,8 @@
* @param port the port to use.
*/
public SwitchPort(Dpid dpid, PortNumber port) {
- Validate.notNull(dpid);
- Validate.notNull(port);
- this.dpid = dpid;
- this.port = port;
+ this.dpid = checkNotNull(dpid);
+ this.port = checkNotNull(port);
}
/**
diff --git a/src/test/java/net/onrc/onos/core/util/LinkTupleTest.java b/src/test/java/net/onrc/onos/core/util/LinkTupleTest.java
index 06cce85..290b136 100644
--- a/src/test/java/net/onrc/onos/core/util/LinkTupleTest.java
+++ b/src/test/java/net/onrc/onos/core/util/LinkTupleTest.java
@@ -49,7 +49,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testLinkTupleSwitchPortSwitchPortFailsOnNull1() {
new LinkTuple(null, DST);
}
@@ -57,7 +57,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testLinkTupleSwitchPortSwitchPortFailsOnNull2() {
new LinkTuple(SRC, null);
}
@@ -79,7 +79,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testLinkTupleDpidPortNumberDpidPortNumberFailOnNull1() {
new LinkTuple(null, SRC_PORT_NUM, DST_DPID, DST_PORT_NUM);
}
@@ -87,7 +87,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testLinkTupleDpidPortNumberDpidPortNumberFailOnNull2() {
new LinkTuple(SRC_DPID, null, DST_DPID, DST_PORT_NUM);
}
@@ -95,7 +95,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testLinkTupleDpidPortNumberDpidPortNumberFailOnNull3() {
new LinkTuple(SRC_DPID, SRC_PORT_NUM, null, DST_PORT_NUM);
}
@@ -103,7 +103,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testLinkTupleDpidPortNumberDpidPortNumberFailOnNull4() {
new LinkTuple(SRC_DPID, SRC_PORT_NUM, DST_DPID, null);
}
diff --git a/src/test/java/net/onrc/onos/core/util/SwitchPortTest.java b/src/test/java/net/onrc/onos/core/util/SwitchPortTest.java
index 1c01e8f..2832dc1 100644
--- a/src/test/java/net/onrc/onos/core/util/SwitchPortTest.java
+++ b/src/test/java/net/onrc/onos/core/util/SwitchPortTest.java
@@ -30,7 +30,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testSwitchPortDpidPortNumberFailOnNull1() {
new SwitchPort(null, PORT_NUM);
}
@@ -38,7 +38,7 @@
/**
* Tests to confirm constructors input validation.
*/
- @Test(expected = IllegalArgumentException.class)
+ @Test(expected = NullPointerException.class)
public void testSwitchPortDpidPortNumberFailOnNull2() {
new SwitchPort(DPID, null);
}