Refactor: improve null safety by using empty list instead of null
Change-Id: I443942ef82819e0c27df2c2acd45eb9106038992
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
index 2269aa0..2a4aaeb 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/ConnectivityIntent.java
@@ -23,6 +23,7 @@
import org.onlab.onos.net.flow.TrafficTreatment;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -61,7 +62,7 @@
Collection<NetworkResource> resources,
TrafficSelector selector,
TrafficTreatment treatment) {
- this(id, appId, resources, selector, treatment, null);
+ this(id, appId, resources, selector, treatment, Collections.emptyList());
}
/**
@@ -87,7 +88,7 @@
super(id, appId, resources);
this.selector = checkNotNull(selector);
this.treatment = checkNotNull(treatment);
- this.constraints = constraints;
+ this.constraints = checkNotNull(constraints);
}
/**
@@ -97,7 +98,7 @@
super();
this.selector = null;
this.treatment = null;
- this.constraints = null;
+ this.constraints = Collections.emptyList();
}
/**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
index 893270a..24a3bca 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/HostToHostIntent.java
@@ -21,6 +21,7 @@
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
+import java.util.Collections;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -46,7 +47,7 @@
public HostToHostIntent(ApplicationId appId, HostId one, HostId two,
TrafficSelector selector,
TrafficTreatment treatment) {
- this(appId, one, two, selector, treatment, null);
+ this(appId, one, two, selector, treatment, Collections.emptyList());
}
/**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
index b4fdcfb..ce1f6b1 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/LinkCollectionIntent.java
@@ -22,6 +22,7 @@
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -51,7 +52,7 @@
TrafficTreatment treatment,
Set<Link> links,
ConnectPoint egressPoint) {
- this(appId, selector , treatment, links, egressPoint, null);
+ this(appId, selector , treatment, links, egressPoint, Collections.emptyList());
}
/**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
index 90907fb..8c8cbb0 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/MultiPointToSinglePointIntent.java
@@ -22,6 +22,7 @@
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -55,14 +56,7 @@
TrafficTreatment treatment,
Set<ConnectPoint> ingressPoints,
ConnectPoint egressPoint) {
- super(id(MultiPointToSinglePointIntent.class, selector, treatment,
- ingressPoints, egressPoint), appId, null, selector, treatment);
-
- checkNotNull(ingressPoints);
- checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
-
- this.ingressPoints = Sets.newHashSet(ingressPoints);
- this.egressPoint = checkNotNull(egressPoint);
+ this(appId, selector, treatment, ingressPoints, egressPoint, Collections.emptyList());
}
/**
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
index 9f8816d..7a0e365 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
@@ -15,6 +15,7 @@
*/
package org.onlab.onos.net.intent;
+import java.util.Collections;
import java.util.List;
import com.google.common.base.MoreObjects;
@@ -42,9 +43,7 @@
*/
public PathIntent(ApplicationId appId, TrafficSelector selector,
TrafficTreatment treatment, Path path) {
- super(id(PathIntent.class, selector, treatment, path), appId,
- resources(path.links()), selector, treatment);
- this.path = path;
+ this(appId, selector, treatment, path, Collections.emptyList());
}
/**