Committed by
Gerrit Code Review
Merge "Refactor: improve null safety by using empty list instead of null"
Showing
5 changed files
with
12 additions
and
16 deletions
... | @@ -23,6 +23,7 @@ import org.onlab.onos.net.flow.TrafficSelector; | ... | @@ -23,6 +23,7 @@ import org.onlab.onos.net.flow.TrafficSelector; |
23 | import org.onlab.onos.net.flow.TrafficTreatment; | 23 | import org.onlab.onos.net.flow.TrafficTreatment; |
24 | 24 | ||
25 | import java.util.Collection; | 25 | import java.util.Collection; |
26 | +import java.util.Collections; | ||
26 | import java.util.List; | 27 | import java.util.List; |
27 | 28 | ||
28 | import static com.google.common.base.Preconditions.checkNotNull; | 29 | import static com.google.common.base.Preconditions.checkNotNull; |
... | @@ -61,7 +62,7 @@ public abstract class ConnectivityIntent extends Intent { | ... | @@ -61,7 +62,7 @@ public abstract class ConnectivityIntent extends Intent { |
61 | Collection<NetworkResource> resources, | 62 | Collection<NetworkResource> resources, |
62 | TrafficSelector selector, | 63 | TrafficSelector selector, |
63 | TrafficTreatment treatment) { | 64 | TrafficTreatment treatment) { |
64 | - this(id, appId, resources, selector, treatment, null); | 65 | + this(id, appId, resources, selector, treatment, Collections.emptyList()); |
65 | } | 66 | } |
66 | 67 | ||
67 | /** | 68 | /** |
... | @@ -87,7 +88,7 @@ public abstract class ConnectivityIntent extends Intent { | ... | @@ -87,7 +88,7 @@ public abstract class ConnectivityIntent extends Intent { |
87 | super(id, appId, resources); | 88 | super(id, appId, resources); |
88 | this.selector = checkNotNull(selector); | 89 | this.selector = checkNotNull(selector); |
89 | this.treatment = checkNotNull(treatment); | 90 | this.treatment = checkNotNull(treatment); |
90 | - this.constraints = constraints; | 91 | + this.constraints = checkNotNull(constraints); |
91 | } | 92 | } |
92 | 93 | ||
93 | /** | 94 | /** |
... | @@ -97,7 +98,7 @@ public abstract class ConnectivityIntent extends Intent { | ... | @@ -97,7 +98,7 @@ public abstract class ConnectivityIntent extends Intent { |
97 | super(); | 98 | super(); |
98 | this.selector = null; | 99 | this.selector = null; |
99 | this.treatment = null; | 100 | this.treatment = null; |
100 | - this.constraints = null; | 101 | + this.constraints = Collections.emptyList(); |
101 | } | 102 | } |
102 | 103 | ||
103 | /** | 104 | /** | ... | ... |
... | @@ -21,6 +21,7 @@ import org.onlab.onos.net.HostId; | ... | @@ -21,6 +21,7 @@ import org.onlab.onos.net.HostId; |
21 | import org.onlab.onos.net.flow.TrafficSelector; | 21 | import org.onlab.onos.net.flow.TrafficSelector; |
22 | import org.onlab.onos.net.flow.TrafficTreatment; | 22 | import org.onlab.onos.net.flow.TrafficTreatment; |
23 | 23 | ||
24 | +import java.util.Collections; | ||
24 | import java.util.List; | 25 | import java.util.List; |
25 | 26 | ||
26 | import static com.google.common.base.Preconditions.checkNotNull; | 27 | import static com.google.common.base.Preconditions.checkNotNull; |
... | @@ -46,7 +47,7 @@ public final class HostToHostIntent extends ConnectivityIntent { | ... | @@ -46,7 +47,7 @@ public final class HostToHostIntent extends ConnectivityIntent { |
46 | public HostToHostIntent(ApplicationId appId, HostId one, HostId two, | 47 | public HostToHostIntent(ApplicationId appId, HostId one, HostId two, |
47 | TrafficSelector selector, | 48 | TrafficSelector selector, |
48 | TrafficTreatment treatment) { | 49 | TrafficTreatment treatment) { |
49 | - this(appId, one, two, selector, treatment, null); | 50 | + this(appId, one, two, selector, treatment, Collections.emptyList()); |
50 | } | 51 | } |
51 | 52 | ||
52 | /** | 53 | /** | ... | ... |
... | @@ -22,6 +22,7 @@ import org.onlab.onos.net.Link; | ... | @@ -22,6 +22,7 @@ import org.onlab.onos.net.Link; |
22 | import org.onlab.onos.net.flow.TrafficSelector; | 22 | import org.onlab.onos.net.flow.TrafficSelector; |
23 | import org.onlab.onos.net.flow.TrafficTreatment; | 23 | import org.onlab.onos.net.flow.TrafficTreatment; |
24 | 24 | ||
25 | +import java.util.Collections; | ||
25 | import java.util.List; | 26 | import java.util.List; |
26 | import java.util.Set; | 27 | import java.util.Set; |
27 | 28 | ||
... | @@ -51,7 +52,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { | ... | @@ -51,7 +52,7 @@ public final class LinkCollectionIntent extends ConnectivityIntent { |
51 | TrafficTreatment treatment, | 52 | TrafficTreatment treatment, |
52 | Set<Link> links, | 53 | Set<Link> links, |
53 | ConnectPoint egressPoint) { | 54 | ConnectPoint egressPoint) { |
54 | - this(appId, selector , treatment, links, egressPoint, null); | 55 | + this(appId, selector , treatment, links, egressPoint, Collections.emptyList()); |
55 | } | 56 | } |
56 | 57 | ||
57 | /** | 58 | /** | ... | ... |
... | @@ -22,6 +22,7 @@ import org.onlab.onos.net.ConnectPoint; | ... | @@ -22,6 +22,7 @@ import org.onlab.onos.net.ConnectPoint; |
22 | import org.onlab.onos.net.flow.TrafficSelector; | 22 | import org.onlab.onos.net.flow.TrafficSelector; |
23 | import org.onlab.onos.net.flow.TrafficTreatment; | 23 | import org.onlab.onos.net.flow.TrafficTreatment; |
24 | 24 | ||
25 | +import java.util.Collections; | ||
25 | import java.util.List; | 26 | import java.util.List; |
26 | import java.util.Set; | 27 | import java.util.Set; |
27 | 28 | ||
... | @@ -55,14 +56,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { | ... | @@ -55,14 +56,7 @@ public final class MultiPointToSinglePointIntent extends ConnectivityIntent { |
55 | TrafficTreatment treatment, | 56 | TrafficTreatment treatment, |
56 | Set<ConnectPoint> ingressPoints, | 57 | Set<ConnectPoint> ingressPoints, |
57 | ConnectPoint egressPoint) { | 58 | ConnectPoint egressPoint) { |
58 | - super(id(MultiPointToSinglePointIntent.class, selector, treatment, | 59 | + this(appId, selector, treatment, ingressPoints, egressPoint, Collections.emptyList()); |
59 | - ingressPoints, egressPoint), appId, null, selector, treatment); | ||
60 | - | ||
61 | - checkNotNull(ingressPoints); | ||
62 | - checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty"); | ||
63 | - | ||
64 | - this.ingressPoints = Sets.newHashSet(ingressPoints); | ||
65 | - this.egressPoint = checkNotNull(egressPoint); | ||
66 | } | 60 | } |
67 | 61 | ||
68 | /** | 62 | /** | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.onos.net.intent; | 16 | package org.onlab.onos.net.intent; |
17 | 17 | ||
18 | +import java.util.Collections; | ||
18 | import java.util.List; | 19 | import java.util.List; |
19 | 20 | ||
20 | import com.google.common.base.MoreObjects; | 21 | import com.google.common.base.MoreObjects; |
... | @@ -42,9 +43,7 @@ public class PathIntent extends ConnectivityIntent { | ... | @@ -42,9 +43,7 @@ public class PathIntent extends ConnectivityIntent { |
42 | */ | 43 | */ |
43 | public PathIntent(ApplicationId appId, TrafficSelector selector, | 44 | public PathIntent(ApplicationId appId, TrafficSelector selector, |
44 | TrafficTreatment treatment, Path path) { | 45 | TrafficTreatment treatment, Path path) { |
45 | - super(id(PathIntent.class, selector, treatment, path), appId, | 46 | + this(appId, selector, treatment, path, Collections.emptyList()); |
46 | - resources(path.links()), selector, treatment); | ||
47 | - this.path = path; | ||
48 | } | 47 | } |
49 | 48 | ||
50 | /** | 49 | /** | ... | ... |
-
Please register or login to post a comment