Use JDK's Optional instead of Guava's Optional
Change-Id: Ia37b2977ede215363374e292b5565f007f1d6483
Showing
2 changed files
with
10 additions
and
11 deletions
... | @@ -15,15 +15,14 @@ | ... | @@ -15,15 +15,14 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.flow; | 16 | package org.onosproject.store.flow; |
17 | 17 | ||
18 | -import static com.google.common.base.Preconditions.checkNotNull; | 18 | +import com.google.common.base.Objects; |
19 | +import org.onosproject.cluster.NodeId; | ||
19 | 20 | ||
20 | import java.util.Collections; | 21 | import java.util.Collections; |
21 | import java.util.List; | 22 | import java.util.List; |
23 | +import java.util.Optional; | ||
22 | 24 | ||
23 | -import org.onosproject.cluster.NodeId; | 25 | +import static com.google.common.base.Preconditions.checkNotNull; |
24 | - | ||
25 | -import com.google.common.base.Objects; | ||
26 | -import com.google.common.base.Optional; | ||
27 | 26 | ||
28 | /** | 27 | /** |
29 | * Class to represent placement information about Master/Backup copy. | 28 | * Class to represent placement information about Master/Backup copy. |
... | @@ -40,7 +39,7 @@ public final class ReplicaInfo { | ... | @@ -40,7 +39,7 @@ public final class ReplicaInfo { |
40 | * @param backups list of NodeId, where backup copies should be placed | 39 | * @param backups list of NodeId, where backup copies should be placed |
41 | */ | 40 | */ |
42 | public ReplicaInfo(NodeId master, List<NodeId> backups) { | 41 | public ReplicaInfo(NodeId master, List<NodeId> backups) { |
43 | - this.master = Optional.fromNullable(master); | 42 | + this.master = Optional.ofNullable(master); |
44 | this.backups = checkNotNull(backups); | 43 | this.backups = checkNotNull(backups); |
45 | } | 44 | } |
46 | 45 | ||
... | @@ -79,7 +78,7 @@ public final class ReplicaInfo { | ... | @@ -79,7 +78,7 @@ public final class ReplicaInfo { |
79 | 78 | ||
80 | // for Serializer | 79 | // for Serializer |
81 | private ReplicaInfo() { | 80 | private ReplicaInfo() { |
82 | - this.master = Optional.absent(); | 81 | + this.master = Optional.empty(); |
83 | this.backups = Collections.emptyList(); | 82 | this.backups = Collections.emptyList(); |
84 | } | 83 | } |
85 | } | 84 | } | ... | ... |
... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.flow.impl; | 16 | package org.onosproject.store.flow.impl; |
17 | 17 | ||
18 | -import com.google.common.base.Optional; | ||
19 | import com.google.common.collect.Maps; | 18 | import com.google.common.collect.Maps; |
20 | import org.junit.After; | 19 | import org.junit.After; |
21 | import org.junit.Before; | 20 | import org.junit.Before; |
... | @@ -38,6 +37,7 @@ import org.onosproject.store.flow.ReplicaInfoService; | ... | @@ -38,6 +37,7 @@ import org.onosproject.store.flow.ReplicaInfoService; |
38 | import java.util.Collections; | 37 | import java.util.Collections; |
39 | import java.util.LinkedList; | 38 | import java.util.LinkedList; |
40 | import java.util.Map; | 39 | import java.util.Map; |
40 | +import java.util.Optional; | ||
41 | import java.util.concurrent.CountDownLatch; | 41 | import java.util.concurrent.CountDownLatch; |
42 | import java.util.concurrent.TimeUnit; | 42 | import java.util.concurrent.TimeUnit; |
43 | 43 | ||
... | @@ -89,7 +89,7 @@ public class ReplicaInfoManagerTest { | ... | @@ -89,7 +89,7 @@ public class ReplicaInfoManagerTest { |
89 | assertEquals(Collections.emptyList(), info1.backups()); | 89 | assertEquals(Collections.emptyList(), info1.backups()); |
90 | 90 | ||
91 | ReplicaInfo info2 = service.getReplicaInfoFor(DID2); | 91 | ReplicaInfo info2 = service.getReplicaInfoFor(DID2); |
92 | - assertEquals("There's no master", Optional.absent(), info2.master()); | 92 | + assertEquals("There's no master", Optional.empty(), info2.master()); |
93 | // backups are always empty for now | 93 | // backups are always empty for now |
94 | assertEquals(Collections.emptyList(), info2.backups()); | 94 | assertEquals(Collections.emptyList(), info2.backups()); |
95 | } | 95 | } |
... | @@ -114,9 +114,9 @@ public class ReplicaInfoManagerTest { | ... | @@ -114,9 +114,9 @@ public class ReplicaInfoManagerTest { |
114 | 114 | ||
115 | 115 | ||
116 | MasterNodeCheck(CountDownLatch latch, DeviceId did, | 116 | MasterNodeCheck(CountDownLatch latch, DeviceId did, |
117 | - NodeId nid) { | 117 | + NodeId nid) { |
118 | this.latch = latch; | 118 | this.latch = latch; |
119 | - this.expectedMaster = Optional.fromNullable(nid); | 119 | + this.expectedMaster = Optional.ofNullable(nid); |
120 | this.expectedDevice = did; | 120 | this.expectedDevice = did; |
121 | } | 121 | } |
122 | 122 | ... | ... |
-
Please register or login to post a comment