DefaultPort
- avoid null and use emptySet - Copy given IpAddress Set to make this instance immutable Change-Id: I55e8f6700ce2bc2883848c26947e6422bc72e1bc
Showing
1 changed file
with
4 additions
and
2 deletions
... | @@ -8,6 +8,8 @@ import java.util.Set; | ... | @@ -8,6 +8,8 @@ import java.util.Set; |
8 | 8 | ||
9 | import org.onlab.packet.IpPrefix; | 9 | import org.onlab.packet.IpPrefix; |
10 | 10 | ||
11 | +import com.google.common.collect.ImmutableSet; | ||
12 | + | ||
11 | /** | 13 | /** |
12 | * Default port implementation. | 14 | * Default port implementation. |
13 | */ | 15 | */ |
... | @@ -45,8 +47,8 @@ public class DefaultPort implements Port { | ... | @@ -45,8 +47,8 @@ public class DefaultPort implements Port { |
45 | this.element = element; | 47 | this.element = element; |
46 | this.number = number; | 48 | this.number = number; |
47 | this.isEnabled = isEnabled; | 49 | this.isEnabled = isEnabled; |
48 | - this.ipAddresses = (ipAddresses == null) ? null : | 50 | + this.ipAddresses = (ipAddresses == null) ? Collections.<IpPrefix>emptySet() : |
49 | - Collections.unmodifiableSet(ipAddresses); | 51 | + ImmutableSet.copyOf(ipAddresses); |
50 | } | 52 | } |
51 | 53 | ||
52 | @Override | 54 | @Override | ... | ... |
-
Please register or login to post a comment