Sho SHIMIZU
Committed by Gerrit Code Review

Use dianmond operator

Change-Id: I551dd9443b10ef17832f74a554486b7605e9866a
Showing 18 changed files with 49 additions and 53 deletions
......@@ -234,7 +234,7 @@ public class DistributedAclStore extends AbstractStore implements AclStore {
ruleToDevice.computeIf(ruleId,
deviceIdSet -> (deviceIdSet == null || !deviceIdSet.contains(deviceId)),
(id, deviceIdSet) -> {
Set<DeviceId> newSet = new HashSet<DeviceId>();
Set<DeviceId> newSet = new HashSet<>();
if (deviceIdSet != null) {
newSet.addAll(deviceIdSet);
}
......@@ -248,4 +248,4 @@ public class DistributedAclStore extends AbstractStore implements AclStore {
ruleToDevice.remove(ruleId);
}
}
\ No newline at end of file
}
......
......@@ -34,8 +34,8 @@ public class OpticalNetworkConfig {
private List<OpticalLinkDescription> opticalLinks;
public OpticalNetworkConfig() {
opticalSwitches = new ArrayList<OpticalSwitchDescription>();
opticalLinks = new ArrayList<OpticalLinkDescription>();
opticalSwitches = new ArrayList<>();
opticalLinks = new ArrayList<>();
}
public List<OpticalSwitchDescription> getOpticalSwitches() {
......
......@@ -887,7 +887,7 @@ public class IntentSynchronizer implements FibListener, IntentRequestListener {
checkNotNull(dstMacAddress);
checkNotNull(srcConnectPoint);
Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
Set<ConnectPoint> ingressPoints = new HashSet<>();
ingressPoints.add(srcConnectPoint);
IpPrefix dstIpPrefix = dstIpAddress.toIpPrefix();
......
......@@ -48,7 +48,7 @@ public class DeviceConfiguration implements DeviceProperties {
private static final Logger log = LoggerFactory
.getLogger(DeviceConfiguration.class);
private final List<Integer> allSegmentIds = new ArrayList<Integer>();
private final List<Integer> allSegmentIds = new ArrayList<>();
private final HashMap<DeviceId, SegmentRouterInfo> deviceConfigMap = new HashMap<>();
private final NetworkConfigManager configService;
......@@ -88,7 +88,7 @@ public class DeviceConfiguration implements DeviceProperties {
info.ip = prefix.address();
info.isEdge = ((SegmentRouterConfig) cfg).isEdgeRouter();
info.subnets = new HashMap<>();
info.gatewayIps = new HashMap<PortNumber, Ip4Address>();
info.gatewayIps = new HashMap<>();
for (Subnet s: ((SegmentRouterConfig) cfg).getSubnets()) {
info.subnets.put(PortNumber.portNumber(s.getPortNo()),
Ip4Prefix.valueOf(s.getSubnetIp()));
......
......@@ -109,7 +109,7 @@ public class ECMPShortestPathGraph {
ArrayList<DeviceId> distanceSwArray = distanceDeviceMap
.get(currDistance + 1);
if (distanceSwArray == null) {
distanceSwArray = new ArrayList<DeviceId>();
distanceSwArray = new ArrayList<>();
distanceSwArray.add(reachedDevice);
distanceDeviceMap.put(currDistance + 1, distanceSwArray);
} else {
......@@ -120,7 +120,7 @@ public class ECMPShortestPathGraph {
ArrayList<Link> upstreamLinkArray =
upstreamLinks.get(reachedDevice);
if (upstreamLinkArray == null) {
upstreamLinkArray = new ArrayList<Link>();
upstreamLinkArray = new ArrayList<>();
upstreamLinkArray.add(copyDefaultLink(link));
//upstreamLinkArray.add(link);
upstreamLinks.put(reachedDevice, upstreamLinkArray);
......@@ -183,7 +183,7 @@ public class ECMPShortestPathGraph {
ArrayList<DeviceId> distanceSwArray = distanceDeviceMap
.get(currDistance + 1);
if (distanceSwArray == null) {
distanceSwArray = new ArrayList<DeviceId>();
distanceSwArray = new ArrayList<>();
distanceSwArray.add(reachedDevice);
distanceDeviceMap.put(currDistance + 1, distanceSwArray);
} else {
......@@ -194,7 +194,7 @@ public class ECMPShortestPathGraph {
ArrayList<Link> upstreamLinkArray =
upstreamLinks.get(reachedDevice);
if (upstreamLinkArray == null) {
upstreamLinkArray = new ArrayList<Link>();
upstreamLinkArray = new ArrayList<>();
upstreamLinkArray.add(copyDefaultLink(link));
upstreamLinks.put(reachedDevice, upstreamLinkArray);
} else {
......@@ -234,7 +234,7 @@ public class ECMPShortestPathGraph {
for (Link upstreamLink : upstreamLinks.get(dstDeviceDeviceId)) {
/* Deep clone the path object */
Path sofarPath;
ArrayList<Link> sofarLinks = new ArrayList<Link>();
ArrayList<Link> sofarLinks = new ArrayList<>();
if (path != null && !path.links().isEmpty()) {
sofarLinks.addAll(path.links());
}
......@@ -288,12 +288,10 @@ public class ECMPShortestPathGraph {
public HashMap<Integer, HashMap<DeviceId,
ArrayList<Path>>> getCompleteLearnedDeviceesAndPaths() {
HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> pathGraph = new
HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>>();
HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> pathGraph = new HashMap<>();
for (Integer itrIndx : distanceDeviceMap.keySet()) {
HashMap<DeviceId, ArrayList<Path>> swMap = new
HashMap<DeviceId, ArrayList<Path>>();
HashMap<DeviceId, ArrayList<Path>> swMap = new HashMap<>();
for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
swMap.put(sw, getECMPPaths(sw));
}
......@@ -314,12 +312,10 @@ public class ECMPShortestPathGraph {
public HashMap<Integer, HashMap<DeviceId,
ArrayList<ArrayList<DeviceId>>>> getAllLearnedSwitchesAndVia() {
HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap =
new HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>>();
HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap = new HashMap<>();
for (Integer itrIndx : distanceDeviceMap.keySet()) {
HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap =
new HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>();
HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap = new HashMap<>();
for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
ArrayList<ArrayList<DeviceId>> swViaArray = new ArrayList<>();
......
......@@ -50,7 +50,7 @@ public class IpHandler {
public IpHandler(SegmentRoutingManager srManager) {
this.srManager = srManager;
this.config = checkNotNull(srManager.deviceConfiguration);
ipPacketQueue = new ConcurrentHashMap<Ip4Address, ConcurrentLinkedQueue<IPv4>>();
ipPacketQueue = new ConcurrentHashMap<>();
}
/**
......@@ -104,7 +104,7 @@ public class IpHandler {
Ip4Address destIpAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress());
if (ipPacketQueue.get(destIpAddress) == null) {
ConcurrentLinkedQueue<IPv4> queue = new ConcurrentLinkedQueue<IPv4>();
ConcurrentLinkedQueue<IPv4> queue = new ConcurrentLinkedQueue<>();
queue.add(ipPacket);
ipPacketQueue.put(destIpAddress, queue);
} else {
......
......@@ -221,7 +221,7 @@ public class RoutingRulePopulator {
Set<DeviceId> nextHops) {
TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<ForwardingObjective.Builder>();
List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<>();
// TODO Handle the case of Bos == false
sbuilder.matchMplsLabel(MplsLabel.mplsLabel(config.getSegmentId(destSwId)));
......
......@@ -69,7 +69,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(neighbors);
log.trace("createGroupsAtEdgeRouter: The size of neighbor powerset "
+ "for sw {} is {}", deviceId, powerSet.size());
Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : powerSet) {
if (combo.isEmpty()) {
continue;
......@@ -148,7 +148,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
Set<DeviceId> updatedNeighbors) {
Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors);
Set<DeviceId> tmp = new HashSet<DeviceId>();
Set<DeviceId> tmp = new HashSet<>();
tmp.addAll(updatedNeighbors);
tmp.remove(impactedNeighbor);
Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp);
......@@ -156,7 +156,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
// Compute the impacted neighbor sets
powerSet.removeAll(tmpPowerSet);
Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : powerSet) {
if (combo.isEmpty()) {
continue;
......
......@@ -371,7 +371,7 @@ public class DefaultGroupHandler {
if (devicePortMap.get(neighborId) != null) {
devicePortMap.get(neighborId).add(portToNeighbor);
} else {
Set<PortNumber> ports = new HashSet<PortNumber>();
Set<PortNumber> ports = new HashSet<>();
ports.add(portToNeighbor);
devicePortMap.put(neighborId, ports);
}
......@@ -383,8 +383,8 @@ public class DefaultGroupHandler {
}
protected Set<Set<DeviceId>> getPowerSetOfNeighbors(Set<DeviceId> neighbors) {
List<DeviceId> list = new ArrayList<DeviceId>(neighbors);
Set<Set<DeviceId>> sets = new HashSet<Set<DeviceId>>();
List<DeviceId> list = new ArrayList<>(neighbors);
Set<Set<DeviceId>> sets = new HashSet<>();
// get the number of elements in the neighbors
int elements = list.size();
// the number of members of a power set is 2^n
......@@ -394,7 +394,7 @@ public class DefaultGroupHandler {
// run a binary counter for the number of power elements
// NOTE: Exclude empty set
for (long i = 1; i < powerElements; i++) {
Set<DeviceId> neighborSubSet = new HashSet<DeviceId>();
Set<DeviceId> neighborSubSet = new HashSet<>();
for (int j = 0; j < elements; j++) {
if ((i >> j) % 2 == 1) {
neighborSubSet.add(list.get(j));
......@@ -411,7 +411,7 @@ public class DefaultGroupHandler {
protected List<Integer> getSegmentIdsTobePairedWithNeighborSet(Set<DeviceId> neighbors) {
List<Integer> nsSegmentIds = new ArrayList<Integer>();
List<Integer> nsSegmentIds = new ArrayList<>();
// Always pair up with no edge label
// If (neighbors.size() == 1) {
......
......@@ -63,7 +63,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
sets = filterEdgeRouterOnlyPairings(sets);
log.debug("createGroupsAtTransitRouter: The size of neighbor powerset "
+ "for sw {} is {}", deviceId, sets.size());
Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : sets) {
if (combo.isEmpty()) {
continue;
......@@ -137,7 +137,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
Set<DeviceId> updatedNeighbors) {
Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors);
Set<DeviceId> tmp = new HashSet<DeviceId>();
Set<DeviceId> tmp = new HashSet<>();
tmp.addAll(updatedNeighbors);
tmp.remove(impactedNeighbor);
Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp);
......@@ -146,7 +146,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
powerSet.removeAll(tmpPowerSet);
powerSet = filterEdgeRouterOnlyPairings(powerSet);
Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : powerSet) {
if (combo.isEmpty()) {
continue;
......@@ -163,7 +163,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
}
private Set<Set<DeviceId>> filterEdgeRouterOnlyPairings(Set<Set<DeviceId>> sets) {
Set<Set<DeviceId>> fiteredSets = new HashSet<Set<DeviceId>>();
Set<Set<DeviceId>> fiteredSets = new HashSet<>();
for (Set<DeviceId> deviceSubSet : sets) {
if (deviceSubSet.size() > 1) {
boolean avoidEdgeRouterPairing = true;
......
......@@ -44,7 +44,7 @@ public class NeighborSet {
public NeighborSet(Set<DeviceId> neighbors) {
checkNotNull(neighbors);
this.edgeLabel = NO_EDGE_LABEL;
this.neighbors = new HashSet<DeviceId>();
this.neighbors = new HashSet<>();
this.neighbors.addAll(neighbors);
}
......@@ -57,7 +57,7 @@ public class NeighborSet {
public NeighborSet(Set<DeviceId> neighbors, int edgeLabel) {
checkNotNull(neighbors);
this.edgeLabel = edgeLabel;
this.neighbors = new HashSet<DeviceId>();
this.neighbors = new HashSet<>();
this.neighbors.addAll(neighbors);
}
......@@ -66,7 +66,7 @@ public class NeighborSet {
*/
public NeighborSet() {
this.edgeLabel = NO_EDGE_LABEL;
this.neighbors = new HashSet<DeviceId>();
this.neighbors = new HashSet<>();
}
/**
......
......@@ -44,7 +44,7 @@ public class SetTestAddCommand extends AbstractShellCommand {
String[] values = null;
Set<String> set;
Set<String> toAdd = new HashSet<String>();
Set<String> toAdd = new HashSet<>();
Serializer serializer = Serializer.using(
......
......@@ -49,7 +49,7 @@ public class SetTestGetCommand extends AbstractShellCommand {
String[] values = null;
Set<String> set;
Set<String> toCheck = new HashSet<String>();
Set<String> toCheck = new HashSet<>();
String output = "";
Serializer serializer = Serializer.using(
......
......@@ -54,7 +54,7 @@ public class SetTestRemoveCommand extends AbstractShellCommand {
String[] values = null;
Set<String> set;
Set<String> givenValues = new HashSet<String>();
Set<String> givenValues = new HashSet<>();
Serializer serializer = Serializer.using(
new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
......
......@@ -626,7 +626,7 @@ public class VTNManager implements VTNService {
VirtualPort port = virtualPortService.getPort(portId);
TenantNetwork network = tenantNetworkService
.getNetwork(port.networkId());
Collection<String> ifaceIds = new HashSet<String>();
Collection<String> ifaceIds = new HashSet<>();
Collection<VirtualPort> ports = virtualPortService
.getPorts(network.id());
Sets.newHashSet(ports).stream()
......
......@@ -149,7 +149,7 @@ public class SubnetWebResource extends AbstractWebResource {
throws IOException {
try {
SubnetId subId = SubnetId.subnetId(id);
Set<SubnetId> subIds = new HashSet<SubnetId>();
Set<SubnetId> subIds = new HashSet<>();
subIds.add(subId);
get(SubnetService.class).removeSubnets(subIds);
return Response.status(201).entity("SUCCESS").build();
......@@ -183,7 +183,7 @@ public class SubnetWebResource extends AbstractWebResource {
*/
public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
checkNotNull(subnetNodes, JSON_NOT_NULL);
Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
Map<SubnetId, Subnet> subMap = new HashMap<>();
for (JsonNode subnetNode : subnetNodes) {
if (!subnetNode.hasNonNull("id")) {
return null;
......@@ -229,7 +229,7 @@ public class SubnetWebResource extends AbstractWebResource {
checkNotNull(subnetNodes, JSON_NOT_NULL);
checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
Map<SubnetId, Subnet> subMap = new HashMap<>();
if (!subnetNodes.hasNonNull("id")) {
return null;
}
......
......@@ -240,7 +240,7 @@ public class TenantNetworkWebResource extends AbstractWebResource {
@Path("{id}")
public Response deleteNetworks(@PathParam("id") String id) {
log.debug("Deletes network by identifier {}.", id);
Set<TenantNetworkId> networkSet = new HashSet<TenantNetworkId>();
Set<TenantNetworkId> networkSet = new HashSet<>();
networkSet.add(TenantNetworkId.networkId(id));
Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)
.removeNetworks(networkSet), NETWORK_NOT_FOUND);
......
......@@ -131,7 +131,7 @@ public class VirtualPortWebResource extends AbstractWebResource {
@Path("{portUUID}")
@DELETE
public Response deletePorts(@PathParam("portUUID") String id) {
Set<VirtualPortId> vPortIds = new HashSet<VirtualPortId>();
Set<VirtualPortId> vPortIds = new HashSet<>();
try {
if (id != null) {
vPortIds.add(VirtualPortId.portId(id));
......@@ -201,8 +201,8 @@ public class VirtualPortWebResource extends AbstractWebResource {
*/
public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {
checkNotNull(vPortNodes, JSON_NOT_NULL);
Map<VirtualPortId, VirtualPort> portMap = new HashMap<VirtualPortId, VirtualPort>();
Map<String, String> strMap = new HashMap<String, String>();
Map<VirtualPortId, VirtualPort> portMap = new HashMap<>();
Map<String, String> strMap = new HashMap<>();
for (JsonNode vPortnode : vPortNodes) {
VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")
.asText());
......@@ -220,7 +220,7 @@ public class VirtualPortWebResource extends AbstractWebResource {
.asText());
String deviceOwner = vPortnode.get("device_owner").asText();
JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
Set<FixedIp> fixedIps = new HashSet<FixedIp>();
Set<FixedIp> fixedIps = new HashSet<>();
for (JsonNode fixedIpNode : fixedIpNodes) {
FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
fixedIps.add(fixedIp);
......@@ -265,8 +265,8 @@ public class VirtualPortWebResource extends AbstractWebResource {
*/
public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {
checkNotNull(vPortNodes, JSON_NOT_NULL);
Map<VirtualPortId, VirtualPort> vportMap = new HashMap<VirtualPortId, VirtualPort>();
Map<String, String> strMap = new HashMap<String, String>();
Map<VirtualPortId, VirtualPort> vportMap = new HashMap<>();
Map<String, String> strMap = new HashMap<>();
VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());
String name = vPortNodes.get("name").asText();
TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")
......@@ -281,7 +281,7 @@ public class VirtualPortWebResource extends AbstractWebResource {
.asText());
String deviceOwner = vPortNodes.get("device_owner").asText();
JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
Set<FixedIp> fixedIps = new HashSet<FixedIp>();
Set<FixedIp> fixedIps = new HashSet<>();
for (JsonNode fixedIpNode : fixedIpNodes) {
FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
fixedIps.add(fixedIp);
......