Sho SHIMIZU
Committed by Gerrit Code Review

Use diamond operator

Change-Id: I9bb7e90ce7f45e65b4081a5bf85570b97e44712e
......@@ -83,8 +83,7 @@ public class SimpleGroupStore
private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>>
extraneousGroupEntriesById = new ConcurrentHashMap<>();
private final HashMap<DeviceId, Boolean> deviceAuditStatus =
new HashMap<DeviceId, Boolean>();
private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>();
private final AtomicInteger groupIdGen = new AtomicInteger();
......@@ -358,8 +357,7 @@ public class SimpleGroupStore
UpdateType type,
GroupBuckets buckets) {
GroupBuckets oldBuckets = oldGroup.buckets();
List<GroupBucket> newBucketList = new ArrayList<GroupBucket>(
oldBuckets.buckets());
List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets());
boolean groupDescUpdated = false;
if (type == UpdateType.ADD) {
......
......@@ -205,10 +205,10 @@ public class SimpleGroupStoreTest {
private void testStoreAndGetGroup(GroupKey key) {
PortNumber[] ports = {PortNumber.portNumber(31),
PortNumber.portNumber(32)};
List<PortNumber> outPorts = new ArrayList<PortNumber>();
List<PortNumber> outPorts = new ArrayList<>();
outPorts.addAll(Arrays.asList(ports));
List<GroupBucket> buckets = new ArrayList<GroupBucket>();
List<GroupBucket> buckets = new ArrayList<>();
for (PortNumber portNumber: outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
......@@ -271,7 +271,7 @@ public class SimpleGroupStoreTest {
Group existingGroup = simpleGroupStore.getGroup(D1, currKey);
int totalPkts = 0;
int totalBytes = 0;
List<GroupBucket> newBucketList = new ArrayList<GroupBucket>();
List<GroupBucket> newBucketList = new ArrayList<>();
for (GroupBucket bucket:existingGroup.buckets().buckets()) {
StoredGroupBucketEntry newBucket =
(StoredGroupBucketEntry)
......@@ -302,15 +302,15 @@ public class SimpleGroupStoreTest {
// Testing updateGroupDescription for ADD operation from northbound
private void testAddBuckets(GroupKey currKey, GroupKey addKey) {
Group existingGroup = simpleGroupStore.getGroup(D1, currKey);
List<GroupBucket> buckets = new ArrayList<GroupBucket>();
List<GroupBucket> buckets = new ArrayList<>();
buckets.addAll(existingGroup.buckets().buckets());
PortNumber[] newNeighborPorts = {PortNumber.portNumber(41),
PortNumber.portNumber(42)};
List<PortNumber> newOutPorts = new ArrayList<PortNumber>();
List<PortNumber> newOutPorts = new ArrayList<>();
newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0]));
List<GroupBucket> toAddBuckets = new ArrayList<GroupBucket>();
List<GroupBucket> toAddBuckets = new ArrayList<>();
for (PortNumber portNumber: newOutPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
......@@ -340,10 +340,10 @@ public class SimpleGroupStoreTest {
// Testing updateGroupDescription for REMOVE operation from northbound
private void testRemoveBuckets(GroupKey currKey, GroupKey removeKey) {
Group existingGroup = simpleGroupStore.getGroup(D1, currKey);
List<GroupBucket> buckets = new ArrayList<GroupBucket>();
List<GroupBucket> buckets = new ArrayList<>();
buckets.addAll(existingGroup.buckets().buckets());
List<GroupBucket> toRemoveBuckets = new ArrayList<GroupBucket>();
List<GroupBucket> toRemoveBuckets = new ArrayList<>();
// There should be 4 buckets in the current group
toRemoveBuckets.add(buckets.remove(0));
......@@ -405,11 +405,11 @@ public class SimpleGroupStoreTest {
GroupKey key = new DefaultGroupKey("group1".getBytes());
PortNumber[] ports = {PortNumber.portNumber(31),
PortNumber.portNumber(32)};
List<PortNumber> outPorts = new ArrayList<PortNumber>();
List<PortNumber> outPorts = new ArrayList<>();
outPorts.add(ports[0]);
outPorts.add(ports[1]);
List<GroupBucket> buckets = new ArrayList<GroupBucket>();
List<GroupBucket> buckets = new ArrayList<>();
for (PortNumber portNumber: outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
......
......@@ -44,7 +44,6 @@ import org.onosproject.net.provider.ProviderId;
import org.onosproject.store.AbstractStore;
import org.slf4j.Logger;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
......@@ -280,7 +279,7 @@ public class SimpleLinkStore
*/
private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() {
return synchronizedSetMultimap(
Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(),
Multimaps.newSetMultimap(new ConcurrentHashMap<>(),
() -> Sets.newConcurrentHashSet()));
}
......
......@@ -276,10 +276,10 @@ public class GroupManagerTest {
PortNumber[] addPorts = {PortNumber.portNumber(51),
PortNumber.portNumber(52)};
List<PortNumber> outPorts;
outPorts = new ArrayList<PortNumber>();
outPorts = new ArrayList<>();
outPorts.addAll(Arrays.asList(addPorts));
List<GroupBucket> addBuckets;
addBuckets = new ArrayList<GroupBucket>();
addBuckets = new ArrayList<>();
for (PortNumber portNumber: outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber)
......
......@@ -82,7 +82,7 @@ class DeviceDescriptions {
if (oldOne != null) {
SparseAnnotations merged = union(oldOne.value().annotations(),
newDesc.value().annotations());
newOne = new Timestamped<DeviceDescription>(
newOne = new Timestamped<>(
new DefaultDeviceDescription(newDesc.value(), merged),
newDesc.timestamp());
}
......@@ -104,27 +104,27 @@ class DeviceDescriptions {
switch (newDesc.value().type()) {
case OMS:
OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value());
newOne = new Timestamped<PortDescription>(
newOne = new Timestamped<>(
new OmsPortDescription(
omsDesc, omsDesc.minFrequency(), omsDesc.maxFrequency(), omsDesc.grid(), merged),
newDesc.timestamp());
break;
case OCH:
OchPortDescription ochDesc = (OchPortDescription) (newDesc.value());
newOne = new Timestamped<PortDescription>(
newOne = new Timestamped<>(
new OchPortDescription(
ochDesc, ochDesc.signalType(), ochDesc.isTunable(), ochDesc.lambda(), merged),
newDesc.timestamp());
break;
case ODUCLT:
OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value());
newOne = new Timestamped<PortDescription>(
newOne = new Timestamped<>(
new OduCltPortDescription(
ocDesc, ocDesc.signalType(), merged),
newDesc.timestamp());
break;
default:
newOne = new Timestamped<PortDescription>(
newOne = new Timestamped<>(
new DefaultPortDescription(newDesc.value(), merged),
newDesc.timestamp());
}
......
......@@ -131,8 +131,7 @@ public class DistributedGroupStore
private ExecutorService messageHandlingExecutor;
private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1;
private final HashMap<DeviceId, Boolean> deviceAuditStatus =
new HashMap<DeviceId, Boolean>();
private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>();
private final AtomicInteger groupIdGen = new AtomicInteger();
......@@ -685,8 +684,7 @@ public class DistributedGroupStore
UpdateType type,
GroupBuckets buckets) {
GroupBuckets oldBuckets = oldGroup.buckets();
List<GroupBucket> newBucketList = new ArrayList<GroupBucket>(
oldBuckets.buckets());
List<GroupBucket> newBucketList = new ArrayList<>(oldBuckets.buckets());
boolean groupDescUpdated = false;
if (type == UpdateType.ADD) {
......
......@@ -62,7 +62,6 @@ import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
import org.slf4j.Logger;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
......@@ -551,7 +550,7 @@ public class GossipLinkStore
*/
private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() {
return synchronizedSetMultimap(
Multimaps.newSetMultimap(new ConcurrentHashMap<K, Collection<V>>(),
Multimaps.newSetMultimap(new ConcurrentHashMap<>(),
() -> Sets.newConcurrentHashSet()));
}
......
......@@ -45,9 +45,9 @@ final class RoleValue {
* Constructs empty RoleValue.
*/
public RoleValue() {
value.put(MastershipRole.MASTER, new LinkedList<NodeId>());
value.put(MastershipRole.STANDBY, new LinkedList<NodeId>());
value.put(MastershipRole.NONE, new LinkedList<NodeId>());
value.put(MastershipRole.MASTER, new LinkedList<>());
value.put(MastershipRole.STANDBY, new LinkedList<>());
value.put(MastershipRole.NONE, new LinkedList<>());
}
/**
......
......@@ -15,8 +15,8 @@ public class UpdateResultTest {
@Test
public void testGetters() {
Versioned<String> oldValue = new Versioned<String>("a", 1);
Versioned<String> newValue = new Versioned<String>("b", 2);
Versioned<String> oldValue = new Versioned<>("a", 1);
Versioned<String> newValue = new Versioned<>("b", 2);
UpdateResult<String, String> ur =
new UpdateResult<>(true, "foo", "k", oldValue, newValue);
......@@ -29,8 +29,8 @@ public class UpdateResultTest {
@Test
public void testToMapEvent() {
Versioned<String> oldValue = new Versioned<String>("a", 1);
Versioned<String> newValue = new Versioned<String>("b", 2);
Versioned<String> oldValue = new Versioned<>("a", 1);
Versioned<String> newValue = new Versioned<>("b", 2);
UpdateResult<String, String> ur1 =
new UpdateResult<>(true, "foo", "k", oldValue, newValue);
MapEvent<String, String> event1 = ur1.toMapEvent();
......@@ -59,8 +59,8 @@ public class UpdateResultTest {
@Test
public void testMap() {
Versioned<String> oldValue = new Versioned<String>("a", 1);
Versioned<String> newValue = new Versioned<String>("b", 2);
Versioned<String> oldValue = new Versioned<>("a", 1);
Versioned<String> newValue = new Versioned<>("b", 2);
UpdateResult<String, String> ur1 =
new UpdateResult<>(true, "foo", "k", oldValue, newValue);
UpdateResult<Integer, Integer> ur2 = ur1.map(s -> s.length(), s -> s.length());
......
......@@ -101,7 +101,7 @@ public class ReplicaInfoManagerTest {
// fake MastershipEvent
eventDispatcher.post(new MastershipEvent(Type.MASTER_CHANGED, DID1,
new RoleInfo(NID1, new LinkedList<NodeId>())));
new RoleInfo(NID1, new LinkedList<>())));
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
......