Thomas Vachuska
Committed by Gerrit Code Review

Merge "Refactor: improve null safety by using empty list instead of null"

......@@ -23,6 +23,7 @@ import org.onlab.onos.net.flow.TrafficSelector;
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 @@ public abstract class ConnectivityIntent extends Intent {
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 @@ public abstract class ConnectivityIntent extends Intent {
super(id, appId, resources);
this.selector = checkNotNull(selector);
this.treatment = checkNotNull(treatment);
this.constraints = constraints;
this.constraints = checkNotNull(constraints);
}
/**
......@@ -97,7 +98,7 @@ public abstract class ConnectivityIntent extends Intent {
super();
this.selector = null;
this.treatment = null;
this.constraints = null;
this.constraints = Collections.emptyList();
}
/**
......
......@@ -21,6 +21,7 @@ import org.onlab.onos.net.HostId;
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 final class HostToHostIntent extends ConnectivityIntent {
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());
}
/**
......
......@@ -22,6 +22,7 @@ import org.onlab.onos.net.Link;
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 @@ public final class LinkCollectionIntent extends ConnectivityIntent {
TrafficTreatment treatment,
Set<Link> links,
ConnectPoint egressPoint) {
this(appId, selector , treatment, links, egressPoint, null);
this(appId, selector , treatment, links, egressPoint, Collections.emptyList());
}
/**
......
......@@ -22,6 +22,7 @@ import org.onlab.onos.net.ConnectPoint;
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 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
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());
}
/**
......
......@@ -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 class PathIntent extends ConnectivityIntent {
*/
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());
}
/**
......