Committed by
Gerrit Code Review
Use diamond operator
Change-Id: I9bb7e90ce7f45e65b4081a5bf85570b97e44712e
Showing
10 changed files
with
33 additions
and
39 deletions
... | @@ -83,8 +83,7 @@ public class SimpleGroupStore | ... | @@ -83,8 +83,7 @@ public class SimpleGroupStore |
83 | private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>> | 83 | private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>> |
84 | extraneousGroupEntriesById = new ConcurrentHashMap<>(); | 84 | extraneousGroupEntriesById = new ConcurrentHashMap<>(); |
85 | 85 | ||
86 | - private final HashMap<DeviceId, Boolean> deviceAuditStatus = | 86 | + private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>(); |
87 | - new HashMap<DeviceId, Boolean>(); | ||
88 | 87 | ||
89 | private final AtomicInteger groupIdGen = new AtomicInteger(); | 88 | private final AtomicInteger groupIdGen = new AtomicInteger(); |
90 | 89 | ||
... | @@ -358,8 +357,7 @@ public class SimpleGroupStore | ... | @@ -358,8 +357,7 @@ public class SimpleGroupStore |
358 | UpdateType type, | 357 | UpdateType type, |
359 | GroupBuckets buckets) { | 358 | GroupBuckets buckets) { |
360 | GroupBuckets oldBuckets = oldGroup.buckets(); | 359 | GroupBuckets oldBuckets = oldGroup.buckets(); |
361 | - List<GroupBucket> newBucketList = new ArrayList<GroupBucket>( | 360 | + List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets()); |
362 | - oldBuckets.buckets()); | ||
363 | boolean groupDescUpdated = false; | 361 | boolean groupDescUpdated = false; |
364 | 362 | ||
365 | if (type == UpdateType.ADD) { | 363 | if (type == UpdateType.ADD) { | ... | ... |
... | @@ -205,10 +205,10 @@ public class SimpleGroupStoreTest { | ... | @@ -205,10 +205,10 @@ public class SimpleGroupStoreTest { |
205 | private void testStoreAndGetGroup(GroupKey key) { | 205 | private void testStoreAndGetGroup(GroupKey key) { |
206 | PortNumber[] ports = {PortNumber.portNumber(31), | 206 | PortNumber[] ports = {PortNumber.portNumber(31), |
207 | PortNumber.portNumber(32)}; | 207 | PortNumber.portNumber(32)}; |
208 | - List<PortNumber> outPorts = new ArrayList<PortNumber>(); | 208 | + List<PortNumber> outPorts = new ArrayList<>(); |
209 | outPorts.addAll(Arrays.asList(ports)); | 209 | outPorts.addAll(Arrays.asList(ports)); |
210 | 210 | ||
211 | - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); | 211 | + List<GroupBucket> buckets = new ArrayList<>(); |
212 | for (PortNumber portNumber: outPorts) { | 212 | for (PortNumber portNumber: outPorts) { |
213 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); | 213 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); |
214 | tBuilder.setOutput(portNumber) | 214 | tBuilder.setOutput(portNumber) |
... | @@ -271,7 +271,7 @@ public class SimpleGroupStoreTest { | ... | @@ -271,7 +271,7 @@ public class SimpleGroupStoreTest { |
271 | Group existingGroup = simpleGroupStore.getGroup(D1, currKey); | 271 | Group existingGroup = simpleGroupStore.getGroup(D1, currKey); |
272 | int totalPkts = 0; | 272 | int totalPkts = 0; |
273 | int totalBytes = 0; | 273 | int totalBytes = 0; |
274 | - List<GroupBucket> newBucketList = new ArrayList<GroupBucket>(); | 274 | + List<GroupBucket> newBucketList = new ArrayList<>(); |
275 | for (GroupBucket bucket:existingGroup.buckets().buckets()) { | 275 | for (GroupBucket bucket:existingGroup.buckets().buckets()) { |
276 | StoredGroupBucketEntry newBucket = | 276 | StoredGroupBucketEntry newBucket = |
277 | (StoredGroupBucketEntry) | 277 | (StoredGroupBucketEntry) |
... | @@ -302,15 +302,15 @@ public class SimpleGroupStoreTest { | ... | @@ -302,15 +302,15 @@ public class SimpleGroupStoreTest { |
302 | // Testing updateGroupDescription for ADD operation from northbound | 302 | // Testing updateGroupDescription for ADD operation from northbound |
303 | private void testAddBuckets(GroupKey currKey, GroupKey addKey) { | 303 | private void testAddBuckets(GroupKey currKey, GroupKey addKey) { |
304 | Group existingGroup = simpleGroupStore.getGroup(D1, currKey); | 304 | Group existingGroup = simpleGroupStore.getGroup(D1, currKey); |
305 | - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); | 305 | + List<GroupBucket> buckets = new ArrayList<>(); |
306 | buckets.addAll(existingGroup.buckets().buckets()); | 306 | buckets.addAll(existingGroup.buckets().buckets()); |
307 | 307 | ||
308 | PortNumber[] newNeighborPorts = {PortNumber.portNumber(41), | 308 | PortNumber[] newNeighborPorts = {PortNumber.portNumber(41), |
309 | PortNumber.portNumber(42)}; | 309 | PortNumber.portNumber(42)}; |
310 | - List<PortNumber> newOutPorts = new ArrayList<PortNumber>(); | 310 | + List<PortNumber> newOutPorts = new ArrayList<>(); |
311 | newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0])); | 311 | newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0])); |
312 | 312 | ||
313 | - List<GroupBucket> toAddBuckets = new ArrayList<GroupBucket>(); | 313 | + List<GroupBucket> toAddBuckets = new ArrayList<>(); |
314 | for (PortNumber portNumber: newOutPorts) { | 314 | for (PortNumber portNumber: newOutPorts) { |
315 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); | 315 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); |
316 | tBuilder.setOutput(portNumber) | 316 | tBuilder.setOutput(portNumber) |
... | @@ -340,10 +340,10 @@ public class SimpleGroupStoreTest { | ... | @@ -340,10 +340,10 @@ public class SimpleGroupStoreTest { |
340 | // Testing updateGroupDescription for REMOVE operation from northbound | 340 | // Testing updateGroupDescription for REMOVE operation from northbound |
341 | private void testRemoveBuckets(GroupKey currKey, GroupKey removeKey) { | 341 | private void testRemoveBuckets(GroupKey currKey, GroupKey removeKey) { |
342 | Group existingGroup = simpleGroupStore.getGroup(D1, currKey); | 342 | Group existingGroup = simpleGroupStore.getGroup(D1, currKey); |
343 | - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); | 343 | + List<GroupBucket> buckets = new ArrayList<>(); |
344 | buckets.addAll(existingGroup.buckets().buckets()); | 344 | buckets.addAll(existingGroup.buckets().buckets()); |
345 | 345 | ||
346 | - List<GroupBucket> toRemoveBuckets = new ArrayList<GroupBucket>(); | 346 | + List<GroupBucket> toRemoveBuckets = new ArrayList<>(); |
347 | 347 | ||
348 | // There should be 4 buckets in the current group | 348 | // There should be 4 buckets in the current group |
349 | toRemoveBuckets.add(buckets.remove(0)); | 349 | toRemoveBuckets.add(buckets.remove(0)); |
... | @@ -405,11 +405,11 @@ public class SimpleGroupStoreTest { | ... | @@ -405,11 +405,11 @@ public class SimpleGroupStoreTest { |
405 | GroupKey key = new DefaultGroupKey("group1".getBytes()); | 405 | GroupKey key = new DefaultGroupKey("group1".getBytes()); |
406 | PortNumber[] ports = {PortNumber.portNumber(31), | 406 | PortNumber[] ports = {PortNumber.portNumber(31), |
407 | PortNumber.portNumber(32)}; | 407 | PortNumber.portNumber(32)}; |
408 | - List<PortNumber> outPorts = new ArrayList<PortNumber>(); | 408 | + List<PortNumber> outPorts = new ArrayList<>(); |
409 | outPorts.add(ports[0]); | 409 | outPorts.add(ports[0]); |
410 | outPorts.add(ports[1]); | 410 | outPorts.add(ports[1]); |
411 | 411 | ||
412 | - List<GroupBucket> buckets = new ArrayList<GroupBucket>(); | 412 | + List<GroupBucket> buckets = new ArrayList<>(); |
413 | for (PortNumber portNumber: outPorts) { | 413 | for (PortNumber portNumber: outPorts) { |
414 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); | 414 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); |
415 | tBuilder.setOutput(portNumber) | 415 | tBuilder.setOutput(portNumber) | ... | ... |
... | @@ -44,7 +44,6 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -44,7 +44,6 @@ import org.onosproject.net.provider.ProviderId; |
44 | import org.onosproject.store.AbstractStore; | 44 | import org.onosproject.store.AbstractStore; |
45 | import org.slf4j.Logger; | 45 | import org.slf4j.Logger; |
46 | 46 | ||
47 | -import java.util.Collection; | ||
48 | import java.util.Collections; | 47 | import java.util.Collections; |
49 | import java.util.HashMap; | 48 | import java.util.HashMap; |
50 | import java.util.HashSet; | 49 | import java.util.HashSet; |
... | @@ -280,7 +279,7 @@ public class SimpleLinkStore | ... | @@ -280,7 +279,7 @@ public class SimpleLinkStore |
280 | */ | 279 | */ |
281 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { | 280 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { |
282 | return synchronizedSetMultimap( | 281 | return synchronizedSetMultimap( |
283 | - Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(), | 282 | + Multimaps.newSetMultimap(new ConcurrentHashMap<>(), |
284 | () -> Sets.newConcurrentHashSet())); | 283 | () -> Sets.newConcurrentHashSet())); |
285 | } | 284 | } |
286 | 285 | ... | ... |
... | @@ -276,10 +276,10 @@ public class GroupManagerTest { | ... | @@ -276,10 +276,10 @@ public class GroupManagerTest { |
276 | PortNumber[] addPorts = {PortNumber.portNumber(51), | 276 | PortNumber[] addPorts = {PortNumber.portNumber(51), |
277 | PortNumber.portNumber(52)}; | 277 | PortNumber.portNumber(52)}; |
278 | List<PortNumber> outPorts; | 278 | List<PortNumber> outPorts; |
279 | - outPorts = new ArrayList<PortNumber>(); | 279 | + outPorts = new ArrayList<>(); |
280 | outPorts.addAll(Arrays.asList(addPorts)); | 280 | outPorts.addAll(Arrays.asList(addPorts)); |
281 | List<GroupBucket> addBuckets; | 281 | List<GroupBucket> addBuckets; |
282 | - addBuckets = new ArrayList<GroupBucket>(); | 282 | + addBuckets = new ArrayList<>(); |
283 | for (PortNumber portNumber: outPorts) { | 283 | for (PortNumber portNumber: outPorts) { |
284 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); | 284 | TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); |
285 | tBuilder.setOutput(portNumber) | 285 | tBuilder.setOutput(portNumber) | ... | ... |
... | @@ -82,7 +82,7 @@ class DeviceDescriptions { | ... | @@ -82,7 +82,7 @@ class DeviceDescriptions { |
82 | if (oldOne != null) { | 82 | if (oldOne != null) { |
83 | SparseAnnotations merged = union(oldOne.value().annotations(), | 83 | SparseAnnotations merged = union(oldOne.value().annotations(), |
84 | newDesc.value().annotations()); | 84 | newDesc.value().annotations()); |
85 | - newOne = new Timestamped<DeviceDescription>( | 85 | + newOne = new Timestamped<>( |
86 | new DefaultDeviceDescription(newDesc.value(), merged), | 86 | new DefaultDeviceDescription(newDesc.value(), merged), |
87 | newDesc.timestamp()); | 87 | newDesc.timestamp()); |
88 | } | 88 | } |
... | @@ -104,27 +104,27 @@ class DeviceDescriptions { | ... | @@ -104,27 +104,27 @@ class DeviceDescriptions { |
104 | switch (newDesc.value().type()) { | 104 | switch (newDesc.value().type()) { |
105 | case OMS: | 105 | case OMS: |
106 | OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value()); | 106 | OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value()); |
107 | - newOne = new Timestamped<PortDescription>( | 107 | + newOne = new Timestamped<>( |
108 | new OmsPortDescription( | 108 | new OmsPortDescription( |
109 | omsDesc, omsDesc.minFrequency(), omsDesc.maxFrequency(), omsDesc.grid(), merged), | 109 | omsDesc, omsDesc.minFrequency(), omsDesc.maxFrequency(), omsDesc.grid(), merged), |
110 | newDesc.timestamp()); | 110 | newDesc.timestamp()); |
111 | break; | 111 | break; |
112 | case OCH: | 112 | case OCH: |
113 | OchPortDescription ochDesc = (OchPortDescription) (newDesc.value()); | 113 | OchPortDescription ochDesc = (OchPortDescription) (newDesc.value()); |
114 | - newOne = new Timestamped<PortDescription>( | 114 | + newOne = new Timestamped<>( |
115 | new OchPortDescription( | 115 | new OchPortDescription( |
116 | ochDesc, ochDesc.signalType(), ochDesc.isTunable(), ochDesc.lambda(), merged), | 116 | ochDesc, ochDesc.signalType(), ochDesc.isTunable(), ochDesc.lambda(), merged), |
117 | newDesc.timestamp()); | 117 | newDesc.timestamp()); |
118 | break; | 118 | break; |
119 | case ODUCLT: | 119 | case ODUCLT: |
120 | OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value()); | 120 | OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value()); |
121 | - newOne = new Timestamped<PortDescription>( | 121 | + newOne = new Timestamped<>( |
122 | new OduCltPortDescription( | 122 | new OduCltPortDescription( |
123 | ocDesc, ocDesc.signalType(), merged), | 123 | ocDesc, ocDesc.signalType(), merged), |
124 | newDesc.timestamp()); | 124 | newDesc.timestamp()); |
125 | break; | 125 | break; |
126 | default: | 126 | default: |
127 | - newOne = new Timestamped<PortDescription>( | 127 | + newOne = new Timestamped<>( |
128 | new DefaultPortDescription(newDesc.value(), merged), | 128 | new DefaultPortDescription(newDesc.value(), merged), |
129 | newDesc.timestamp()); | 129 | newDesc.timestamp()); |
130 | } | 130 | } | ... | ... |
... | @@ -131,8 +131,7 @@ public class DistributedGroupStore | ... | @@ -131,8 +131,7 @@ public class DistributedGroupStore |
131 | private ExecutorService messageHandlingExecutor; | 131 | private ExecutorService messageHandlingExecutor; |
132 | private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1; | 132 | private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1; |
133 | 133 | ||
134 | - private final HashMap<DeviceId, Boolean> deviceAuditStatus = | 134 | + private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>(); |
135 | - new HashMap<DeviceId, Boolean>(); | ||
136 | 135 | ||
137 | private final AtomicInteger groupIdGen = new AtomicInteger(); | 136 | private final AtomicInteger groupIdGen = new AtomicInteger(); |
138 | 137 | ||
... | @@ -685,8 +684,7 @@ public class DistributedGroupStore | ... | @@ -685,8 +684,7 @@ public class DistributedGroupStore |
685 | UpdateType type, | 684 | UpdateType type, |
686 | GroupBuckets buckets) { | 685 | GroupBuckets buckets) { |
687 | GroupBuckets oldBuckets = oldGroup.buckets(); | 686 | GroupBuckets oldBuckets = oldGroup.buckets(); |
688 | - List<GroupBucket> newBucketList = new ArrayList<GroupBucket>( | 687 | + List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets()); |
689 | - oldBuckets.buckets()); | ||
690 | boolean groupDescUpdated = false; | 688 | boolean groupDescUpdated = false; |
691 | 689 | ||
692 | if (type == UpdateType.ADD) { | 690 | if (type == UpdateType.ADD) { | ... | ... |
... | @@ -62,7 +62,6 @@ import org.onosproject.store.serializers.custom.DistributedStoreSerializers; | ... | @@ -62,7 +62,6 @@ import org.onosproject.store.serializers.custom.DistributedStoreSerializers; |
62 | import org.slf4j.Logger; | 62 | import org.slf4j.Logger; |
63 | 63 | ||
64 | import java.io.IOException; | 64 | import java.io.IOException; |
65 | -import java.util.Collection; | ||
66 | import java.util.Collections; | 65 | import java.util.Collections; |
67 | import java.util.HashMap; | 66 | import java.util.HashMap; |
68 | import java.util.HashSet; | 67 | import java.util.HashSet; |
... | @@ -551,7 +550,7 @@ public class GossipLinkStore | ... | @@ -551,7 +550,7 @@ public class GossipLinkStore |
551 | */ | 550 | */ |
552 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { | 551 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { |
553 | return synchronizedSetMultimap( | 552 | return synchronizedSetMultimap( |
554 | - Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(), | 553 | + Multimaps.newSetMultimap(new ConcurrentHashMap<>(), |
555 | () -> Sets.newConcurrentHashSet())); | 554 | () -> Sets.newConcurrentHashSet())); |
556 | } | 555 | } |
557 | 556 | ... | ... |
... | @@ -45,9 +45,9 @@ final class RoleValue { | ... | @@ -45,9 +45,9 @@ final class RoleValue { |
45 | * Constructs empty RoleValue. | 45 | * Constructs empty RoleValue. |
46 | */ | 46 | */ |
47 | public RoleValue() { | 47 | public RoleValue() { |
48 | - value.put(MastershipRole.MASTER, new LinkedList<NodeId>()); | 48 | + value.put(MastershipRole.MASTER, new LinkedList<>()); |
49 | - value.put(MastershipRole.STANDBY, new LinkedList<NodeId>()); | 49 | + value.put(MastershipRole.STANDBY, new LinkedList<>()); |
50 | - value.put(MastershipRole.NONE, new LinkedList<NodeId>()); | 50 | + value.put(MastershipRole.NONE, new LinkedList<>()); |
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** | ... | ... |
... | @@ -15,8 +15,8 @@ public class UpdateResultTest { | ... | @@ -15,8 +15,8 @@ public class UpdateResultTest { |
15 | 15 | ||
16 | @Test | 16 | @Test |
17 | public void testGetters() { | 17 | public void testGetters() { |
18 | - Versioned<String> oldValue = new Versioned<String>("a", 1); | 18 | + Versioned<String> oldValue = new Versioned<>("a", 1); |
19 | - Versioned<String> newValue = new Versioned<String>("b", 2); | 19 | + Versioned<String> newValue = new Versioned<>("b", 2); |
20 | UpdateResult<String, String> ur = | 20 | UpdateResult<String, String> ur = |
21 | new UpdateResult<>(true, "foo", "k", oldValue, newValue); | 21 | new UpdateResult<>(true, "foo", "k", oldValue, newValue); |
22 | 22 | ||
... | @@ -29,8 +29,8 @@ public class UpdateResultTest { | ... | @@ -29,8 +29,8 @@ public class UpdateResultTest { |
29 | 29 | ||
30 | @Test | 30 | @Test |
31 | public void testToMapEvent() { | 31 | public void testToMapEvent() { |
32 | - Versioned<String> oldValue = new Versioned<String>("a", 1); | 32 | + Versioned<String> oldValue = new Versioned<>("a", 1); |
33 | - Versioned<String> newValue = new Versioned<String>("b", 2); | 33 | + Versioned<String> newValue = new Versioned<>("b", 2); |
34 | UpdateResult<String, String> ur1 = | 34 | UpdateResult<String, String> ur1 = |
35 | new UpdateResult<>(true, "foo", "k", oldValue, newValue); | 35 | new UpdateResult<>(true, "foo", "k", oldValue, newValue); |
36 | MapEvent<String, String> event1 = ur1.toMapEvent(); | 36 | MapEvent<String, String> event1 = ur1.toMapEvent(); |
... | @@ -59,8 +59,8 @@ public class UpdateResultTest { | ... | @@ -59,8 +59,8 @@ public class UpdateResultTest { |
59 | 59 | ||
60 | @Test | 60 | @Test |
61 | public void testMap() { | 61 | public void testMap() { |
62 | - Versioned<String> oldValue = new Versioned<String>("a", 1); | 62 | + Versioned<String> oldValue = new Versioned<>("a", 1); |
63 | - Versioned<String> newValue = new Versioned<String>("b", 2); | 63 | + Versioned<String> newValue = new Versioned<>("b", 2); |
64 | UpdateResult<String, String> ur1 = | 64 | UpdateResult<String, String> ur1 = |
65 | new UpdateResult<>(true, "foo", "k", oldValue, newValue); | 65 | new UpdateResult<>(true, "foo", "k", oldValue, newValue); |
66 | UpdateResult<Integer, Integer> ur2 = ur1.map(s -> s.length(), s -> s.length()); | 66 | UpdateResult<Integer, Integer> ur2 = ur1.map(s -> s.length(), s -> s.length()); | ... | ... |
... | @@ -101,7 +101,7 @@ public class ReplicaInfoManagerTest { | ... | @@ -101,7 +101,7 @@ public class ReplicaInfoManagerTest { |
101 | 101 | ||
102 | // fake MastershipEvent | 102 | // fake MastershipEvent |
103 | eventDispatcher.post(new MastershipEvent(Type.MASTER_CHANGED, DID1, | 103 | eventDispatcher.post(new MastershipEvent(Type.MASTER_CHANGED, DID1, |
104 | - new RoleInfo(NID1, new LinkedList<NodeId>()))); | 104 | + new RoleInfo(NID1, new LinkedList<>()))); |
105 | 105 | ||
106 | assertTrue(latch.await(1, TimeUnit.SECONDS)); | 106 | assertTrue(latch.await(1, TimeUnit.SECONDS)); |
107 | } | 107 | } | ... | ... |
-
Please register or login to post a comment