Sonar fixes
Rule: Use isEmpty() to check whether the collection is empty or not.
Change-Id: Ib5ab56b2263623b297db56c5cac2c2ee80e12725
diff --git a/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java b/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java
index c7326b8..16d7da3 100644
--- a/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java
+++ b/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java
@@ -235,7 +235,7 @@
ArrayList<ConnectPoint> egressList = (ArrayList<ConnectPoint>) mcastRouteManager.fetchSinks(mRoute);
//If there are no egress ports set return, otherwise forward the packets to their expected port.
- if (egressList.size() == 0) {
+ if (egressList.isEmpty()) {
return;
}
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
index 8e93b80..c1a1bec 100644
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
+++ b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
@@ -710,7 +710,7 @@
Highlights highlights = new Highlights();
paths.removeAll(paths);
tunnelSet = tunnelService.queryTunnel(MPLS);
- if (tunnelSet.size() == 0) {
+ if (tunnelSet.isEmpty()) {
log.warn("Tunnel does not exist");
sendMessage(highlightsMessage(highlights));
return;
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
index 9e215a9..b691f80 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
@@ -559,7 +559,7 @@
}
List<Port> devPorts = srManager.deviceService.getPorts(deviceId);
- if (devPorts == null || devPorts.size() == 0) {
+ if (devPorts == null || devPorts.isEmpty()) {
log.warn("Device {} ports not available. Unable to add MacVlan filters",
deviceId);
return null;
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
index 7eb6894..2bd9932 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
@@ -357,7 +357,7 @@
.map(IpPrefix::getIp4Prefix)
.collect(Collectors.toSet());
- if (subnets.size() == 0) {
+ if (subnets.isEmpty()) {
log.info(NO_SUBNET, connectPoint);
return null;
} else if (subnets.size() > 1) {
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
index 52606cf..b76a04c 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
@@ -655,7 +655,7 @@
log.warn("Neighbor {} is not in the port map yet for dev:{}",
neighborId, deviceId);
return;
- } else if (devicePortMap.get(neighborId).size() == 0) {
+ } else if (devicePortMap.get(neighborId).isEmpty()) {
log.warn("There are no ports for "
+ "the Device {} in the port map yet", neighborId);
return;
diff --git a/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java
index 9b758d4..b4d7acf 100644
--- a/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java
+++ b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java
@@ -358,7 +358,7 @@
.forEach(device -> devices.put(mastershipService.getMasterFor(device.id()), device));
// ensure that we have at least one device per neighbor
- neighbors.forEach(node -> checkState(devices.get(node).size() > 0,
+ neighbors.forEach(node -> checkState(!devices.get(node).isEmpty(),
"There are no devices for {}", node));
// TODO pull this outside so that createIntent can use it
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L2ForwardServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L2ForwardServiceImpl.java
index 7c9c30d..582aad3 100644
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L2ForwardServiceImpl.java
+++ b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L2ForwardServiceImpl.java
@@ -142,7 +142,7 @@
.withSelector(selector).fromApp(appId).makePermanent()
.withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
- if (Sets.newHashSet(localVmPorts).size() == 0) {
+ if (Sets.newHashSet(localVmPorts).isEmpty()) {
flowObjectiveService.forward(deviceId, objective.remove());
} else {
flowObjectiveService.forward(deviceId, objective.add());
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnData.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnData.java
index 2ee889a..c66cba6 100644
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnData.java
+++ b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnData.java
@@ -137,7 +137,7 @@
}
}
});
- if (vPorts.size() == 0) {
+ if (vPorts.isEmpty()) {
return null;
}
return vPorts.get(0);
@@ -168,7 +168,7 @@
}
}
});
- if (vPorts.size() == 0) {
+ if (vPorts.isEmpty()) {
return null;
}
return vPorts.get(0);
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
index ede595f..0b7d0a6 100644
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
@@ -181,7 +181,7 @@
}
}
});
- if (vPorts.size() == 0) {
+ if (vPorts.isEmpty()) {
return null;
}
return vPorts.get(0);
@@ -196,7 +196,7 @@
vPorts.add(p);
}
});
- if (vPorts.size() == 0) {
+ if (vPorts.isEmpty()) {
return null;
}
return vPorts.get(0);
@@ -217,7 +217,7 @@
}
}
});
- if (vPorts.size() == 0) {
+ if (vPorts.isEmpty()) {
return null;
}
return vPorts.get(0);
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
index c2c4632..8691b42 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
@@ -99,7 +99,7 @@
.getFloatingIp(FloatingIpId.of(id)), GET_FAIL);
ObjectNode result = new ObjectMapper().createObjectNode();
- if (fields.size() > 0) {
+ if (!fields.isEmpty()) {
result.set("floatingip",
new FloatingIpCodec().extracFields(sub, this, fields));
} else {
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
index 855209c..332bd41 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
@@ -106,7 +106,7 @@
.getRouter(RouterId.valueOf(id)), NOT_EXIST);
ObjectNode result = new ObjectMapper().createObjectNode();
- if (fields.size() > 0) {
+ if (!fields.isEmpty()) {
result.set("router",
new RouterCodec().extracFields(sub, this, fields));
} else {
diff --git a/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
index aabe72a..d3c68a6 100644
--- a/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
@@ -40,7 +40,7 @@
LabelResourceService lrs = get(LabelResourceService.class);
Collection<LabelResource> result =
lrs.applyFromGlobalPool(Long.parseLong(applyNum));
- if (result.size() > 0) {
+ if (!result.isEmpty()) {
for (Iterator<LabelResource> iterator = result.iterator(); iterator
.hasNext();) {
DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator
diff --git a/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java b/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
index 0ff7bed..dea152d 100644
--- a/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
@@ -45,7 +45,7 @@
LabelResourceService lrs = get(LabelResourceService.class);
Collection<LabelResource> result = lrs.applyFromDevicePool(DeviceId
.deviceId(deviceId), Long.parseLong(applyNum));
- if (result.size() > 0) {
+ if (!result.isEmpty()) {
for (Iterator<LabelResource> iterator = result.iterator(); iterator
.hasNext();) {
DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriver.java b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriver.java
index c54ca46..7ed674b 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/DefaultDriver.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/DefaultDriver.java
@@ -99,7 +99,7 @@
}
}));
}
- return new DefaultDriver(name, completeParents.size() > 0 ? completeParents : other.parents(),
+ return new DefaultDriver(name, !completeParents.isEmpty() ? completeParents : other.parents(),
manufacturer, hwVersion, swVersion,
ImmutableMap.copyOf(behaviours), properties.build());
}
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 623ece1..1fd3935 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -498,7 +498,7 @@
@Override
public TrafficTreatment build() {
- if (deferred.size() == 0 && immediate.size() == 0
+ if (deferred.isEmpty() && immediate.isEmpty()
&& table == null && !clear) {
immediate();
noAction();
diff --git a/core/api/src/main/java/org/onosproject/net/mcast/McastRouteInfo.java b/core/api/src/main/java/org/onosproject/net/mcast/McastRouteInfo.java
index f8d232b..9a47817 100644
--- a/core/api/src/main/java/org/onosproject/net/mcast/McastRouteInfo.java
+++ b/core/api/src/main/java/org/onosproject/net/mcast/McastRouteInfo.java
@@ -62,7 +62,7 @@
}
public boolean isComplete() {
- return ((sink.isPresent() || sinks.size() > 0) && source.isPresent());
+ return ((sink.isPresent() || !sinks.isEmpty()) && source.isPresent());
}
/**
diff --git a/core/api/src/main/java/org/onosproject/net/meter/DefaultMeter.java b/core/api/src/main/java/org/onosproject/net/meter/DefaultMeter.java
index e2e049d..f33c914 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/DefaultMeter.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/DefaultMeter.java
@@ -222,7 +222,7 @@
public DefaultMeter build() {
checkNotNull(deviceId, "Must specify a device");
checkNotNull(bands, "Must have bands.");
- checkArgument(bands.size() > 0, "Must have at least one band.");
+ checkArgument(!bands.isEmpty(), "Must have at least one band.");
checkNotNull(appId, "Must have an application id");
checkNotNull(id, "Must specify a meter id");
return new DefaultMeter(deviceId, id, appId, unit, burst, bands);
diff --git a/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterRequest.java b/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterRequest.java
index 7168928..1ca4466 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterRequest.java
@@ -165,7 +165,7 @@
private void validate() {
checkNotNull(deviceId, "Must specify a device");
checkNotNull(bands, "Must have bands.");
- checkArgument(bands.size() > 0, "Must have at least one band.");
+ checkArgument(!bands.isEmpty(), "Must have at least one band.");
checkNotNull(appId, "Must have an application id");
}
diff --git a/core/api/src/main/java/org/onosproject/net/resource/ContinuousResourceId.java b/core/api/src/main/java/org/onosproject/net/resource/ContinuousResourceId.java
index 0222051..46237e0 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/ContinuousResourceId.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/ContinuousResourceId.java
@@ -93,7 +93,7 @@
@Override
public Optional<DiscreteResourceId> parent() {
- if (components.size() == 0) {
+ if (components.isEmpty()) {
return Optional.empty();
}
if (components.size() == 1) {
diff --git a/core/api/src/main/java/org/onosproject/ui/UiExtension.java b/core/api/src/main/java/org/onosproject/ui/UiExtension.java
index bc0dfc9..17201cb 100644
--- a/core/api/src/main/java/org/onosproject/ui/UiExtension.java
+++ b/core/api/src/main/java/org/onosproject/ui/UiExtension.java
@@ -165,7 +165,7 @@
*/
public Builder(ClassLoader cl, List<UiView> views) {
checkNotNull(cl, "Must provide a class loader");
- checkArgument(views.size() > 0, "Must provide at least one view");
+ checkArgument(!views.isEmpty(), "Must provide at least one view");
classLoader = cl;
viewList = views;
}
diff --git a/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java b/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
index ce5680e..f906546 100644
--- a/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
+++ b/core/api/src/main/java/org/onosproject/ui/topo/NodeSelection.java
@@ -97,7 +97,7 @@
Set<String> unmatched = findLinks(ids);
unmatched = findDevices(unmatched);
unmatched = findHosts(unmatched);
- if (unmatched.size() > 0) {
+ if (!unmatched.isEmpty()) {
log.debug("Skipping unmatched IDs {}", unmatched);
}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/RoleInfoCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/RoleInfoCodec.java
index 2bed282..8e0f0b7 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/RoleInfoCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/RoleInfoCodec.java
@@ -54,7 +54,7 @@
ArrayNode backups = context.mapper().createArrayNode();
roleInfo.backups().forEach(backup -> backups.add(backup.id()));
- if (roleInfo.backups().size() != 0) {
+ if (!roleInfo.backups().isEmpty()) {
result.set(BACKUPS, backups);
}
diff --git a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
index 17df9c4..cd244ff 100644
--- a/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
+++ b/core/net/src/main/java/org/onosproject/net/flow/impl/FlowRuleManager.java
@@ -629,7 +629,7 @@
@Override
public synchronized void run() {
- if (stages.size() > 0) {
+ if (!stages.isEmpty()) {
process(stages.remove(0));
} else if (!hasFailed) {
fops.callback().onSuccess(fops);
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorState.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorState.java
index cb7d63a..369c191 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorState.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/resources/impl/AtomixLeaderElectorState.java
@@ -449,7 +449,7 @@
.filter(r -> r.sessionId() != session.id())
.collect(Collectors.toList());
if (leader.sessionId() == session.id()) {
- if (updatedRegistrations.size() > 0) {
+ if (!updatedRegistrations.isEmpty()) {
return new ElectionState(updatedRegistrations,
updatedRegistrations.get(0),
termCounter.get(),
@@ -474,7 +474,7 @@
.filter(r -> !r.nodeId().equals(nodeId))
.collect(Collectors.toList());
if (leader.nodeId().equals(nodeId)) {
- if (updatedRegistrations.size() > 0) {
+ if (!updatedRegistrations.isEmpty()) {
return new ElectionState(updatedRegistrations,
updatedRegistrations.get(0),
termCounter.get(),
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OplinkRoadm.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OplinkRoadm.java
index 99f2be3..273469b 100644
--- a/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OplinkRoadm.java
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OplinkRoadm.java
@@ -277,7 +277,7 @@
private OplinkPortAdjacency getNeighbor(OFExpPortAdjacency ad) {
for (OFExpPortAdjacencyId adid : ad.getProperties()) {
List<OFExpExtAdId> otns = adid.getAdId();
- if (otns != null && otns.size() > 0) {
+ if (otns != null && !otns.isEmpty()) {
OFExpPortAdidOtn otn = (OFExpPortAdidOtn) otns.get(0);
// ITU-T G.7714 ETH MAC Format (in second 16 bytes of the following)
// |---------------------------------------------------------------------------|
diff --git a/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbControllerConfig.java b/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbControllerConfig.java
index 25210a2..4f93484 100644
--- a/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbControllerConfig.java
+++ b/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbControllerConfig.java
@@ -81,7 +81,7 @@
List<OvsdbNodeId> nodeIds = ovsController.getNodeIds().stream()
.filter(nodeId -> nodeId.getIpAddress().equals(targetIp))
.collect(Collectors.toList());
- if (nodeIds.size() == 0) {
+ if (nodeIds.isEmpty()) {
//TODO decide what port?
ovsController.connect(IpAddress.valueOf(targetIp),
targetPort == null ? TpPort.tpPort(OvsdbConstant.OVSDBPORT) : targetPort);
@@ -92,9 +92,9 @@
.map(ovsController::getOvsdbClient)
.filter(cs -> cs.getBridges().stream().anyMatch(b -> dpidMatches(b, ofDeviceId)))
.collect(Collectors.toList());
- checkState(clientServices.size() > 0, "No clientServices found");
+ checkState(!clientServices.isEmpty(), "No clientServices found");
//FIXME add connection to management address if null --> done ?
- return clientServices.size() > 0 ? clientServices.get(0) : null;
+ return !clientServices.isEmpty() ? clientServices.get(0) : null;
}
private static boolean dpidMatches(OvsdbBridge bridge, DeviceId deviceId) {
diff --git a/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbMirroringConfig.java b/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbMirroringConfig.java
index 9a1896e..58cf117 100644
--- a/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbMirroringConfig.java
+++ b/drivers/ovsdb/src/main/java/org/onosproject/drivers/ovsdb/OvsdbMirroringConfig.java
@@ -124,7 +124,7 @@
List<OvsdbNodeId> nodeIds = ovsController.getNodeIds().stream()
.filter(nodeID -> nodeID.getIpAddress().equals(targetIp))
.collect(Collectors.toList());
- if (nodeIds.size() == 0) {
+ if (nodeIds.isEmpty()) {
//TODO decide what port?
ovsController.connect(IpAddress.valueOf(targetIp),
targetPort == null ? TpPort.tpPort(OvsdbConstant.OVSDBPORT) : targetPort);
@@ -135,9 +135,9 @@
.map(ovsController::getOvsdbClient)
.filter(cs -> cs.getBridges().stream().anyMatch(b -> dpidMatches(b, deviceId)))
.collect(Collectors.toList());
- checkState(clientServices.size() > 0, "No clientServices found");
+ checkState(!clientServices.isEmpty(), "No clientServices found");
//FIXME add connection to management address if null --> done ?
- return clientServices.size() > 0 ? clientServices.get(0) : null;
+ return !clientServices.isEmpty() ? clientServices.get(0) : null;
default:
log.warn("Unmanaged device type");
}
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java
index a9582ab..9b8a2e7 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/tunnel/impl/TunnelManager.java
@@ -209,7 +209,7 @@
Annotations... annotations) {
Collection<Tunnel> tunnels = store.borrowTunnel(consumerId, src,
dst, annotations);
- if (tunnels == null || tunnels.size() == 0) {
+ if (tunnels == null || tunnels.isEmpty()) {
Tunnel tunnel = new DefaultTunnel(null, src, dst, null, null, null,
null, null, annotations);
Set<ProviderId> ids = getProviders();
@@ -228,7 +228,7 @@
Collection<Tunnel> tunnels = store.borrowTunnel(consumerId, src,
dst, type,
annotations);
- if (tunnels == null || tunnels.size() == 0) {
+ if (tunnels == null || tunnels.isEmpty()) {
Tunnel tunnel = new DefaultTunnel(null, src, dst, type, null, null,
null, null, annotations);
Set<ProviderId> ids = getProviders();
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkFlowRuleManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkFlowRuleManager.java
index 31c1415..f6c6e2b 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkFlowRuleManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/virtual/impl/VirtualNetworkFlowRuleManager.java
@@ -251,7 +251,7 @@
@Override
public synchronized void run() {
- if (stages.size() > 0) {
+ if (!stages.isEmpty()) {
process(stages.remove(0));
} else if (!hasFailed) {
fops.callback().onSuccess(fops);
diff --git a/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java b/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java
index 31452ac..0907643 100644
--- a/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java
+++ b/incubator/store/src/main/java/org/onosproject/incubator/store/tunnel/impl/DistributedTunnelStore.java
@@ -307,7 +307,7 @@
orderRelationship.put(appId, orderSet);
TunnelKey key = TunnelKey.tunnelKey(src, dst);
Set<TunnelId> idSet = srcAndDstKeyMap.get(key);
- if (idSet == null || idSet.size() == 0) {
+ if (idSet == null || idSet.isEmpty()) {
return Collections.emptySet();
}
Collection<Tunnel> tunnelSet = new HashSet<Tunnel>();
@@ -337,7 +337,7 @@
orderRelationship.put(appId, orderSet);
TunnelKey key = TunnelKey.tunnelKey(src, dst);
Set<TunnelId> idSet = srcAndDstKeyMap.get(key);
- if (idSet == null || idSet.size() == 0) {
+ if (idSet == null || idSet.isEmpty()) {
return Collections.emptySet();
}
Collection<Tunnel> tunnelSet = new HashSet<Tunnel>();
@@ -364,7 +364,7 @@
boolean isExist = orderSet.contains(order);
Set<TunnelId> idSet = tunnelNameAsKeyMap.get(tunnelName);
- if (idSet == null || idSet.size() == 0) {
+ if (idSet == null || idSet.isEmpty()) {
return Collections.emptySet();
}
Collection<Tunnel> tunnelSet = new HashSet<Tunnel>();
@@ -447,7 +447,7 @@
for (TunnelId id : tunnelIds) {
result.add(tunnelIdAsKeyStore.get(id));
}
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet
+ return result.isEmpty() ? Collections.emptySet() : ImmutableSet
.copyOf(result);
}
@@ -462,7 +462,7 @@
for (TunnelId id : tunnelIds) {
result.add(tunnelIdAsKeyStore.get(id));
}
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet
+ return result.isEmpty() ? Collections.emptySet() : ImmutableSet
.copyOf(result);
}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
index d766f0d..50d63aa 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/As4Path.java
@@ -171,7 +171,7 @@
if ((as4pathSet != null) && (as4pathSeq != null)) {
int iAsLenIndex = cb.writerIndex();
cb.writeByte(0);
- if (as4pathSeq.size() != 0) {
+ if (!as4pathSeq.isEmpty()) {
cb.writeByte(AsPath.ASPATH_SEQ_TYPE);
cb.writeByte(as4pathSeq.size());
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
index f6442d9..db1eed6 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AsPath.java
@@ -208,7 +208,7 @@
if (isaspathSet()) {
int iAsLenIndex = cb.writerIndex();
cb.writeByte(0);
- if (aspathSeq.size() != 0) {
+ if (!aspathSeq.isEmpty()) {
cb.writeByte(ASPATH_SEQ_TYPE);
cb.writeByte(aspathSeq.size());
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
index 406d09c..ae9504b 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
@@ -127,7 +127,7 @@
configPacket[1] = numberOfInterface;
//First time configuration
if (processes == null) {
- if (isisProcesses.size() > 0) {
+ if (!isisProcesses.isEmpty()) {
processes = isisProcesses;
connectPeer();
}
@@ -337,7 +337,7 @@
}
interfaceList.add(isisInterface);
}
- if (interfaceList.size() > 0) {
+ if (!interfaceList.isEmpty()) {
IsisProcess process = new DefaultIsisProcess();
process.setProcessId(jsonNode.path(IsisConstants.PROCESSESID).asText());
process.setIsisInterfaceList(interfaceList);
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
index b75bc3f..43d95d8 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
@@ -73,7 +73,7 @@
isisMessageList.add(message);
}
}
- return (isisMessageList.size() > 0) ? isisMessageList : null;
+ return (!isisMessageList.isEmpty()) ? isisMessageList : null;
}
/**
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIs.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIs.java
index f5cd03b..5c3bb2e 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIs.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIs.java
@@ -134,7 +134,7 @@
List<Byte> byteList = new ArrayList<>();
byteList.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborId()));
byteList.addAll(Bytes.asList(IsisUtil.convertToThreeBytes(this.metric())));
- if (this.teSubTlv.size() > 0) {
+ if (!this.teSubTlv.isEmpty()) {
for (TrafficEngineeringSubTlv trafficEngineeringSubTlv : this.teSubTlv) {
byteList.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv));
}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
index 80bd083..a385376 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
@@ -423,7 +423,7 @@
adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.DOWN.value());
adjacencyStateTlv.setLocalCircuitId(Integer.parseInt(isisInterface.circuitId()));
Set<MacAddress> neighbors = isisInterface.neighbors();
- if (neighbors.size() > 0) {
+ if (!neighbors.isEmpty()) {
IsisNeighbor neighbor = isisInterface.lookup(neighbors.iterator().next());
adjacencyStateTlv.setAdjacencyType((byte) neighbor.interfaceState().value());
adjacencyStateTlv.setNeighborSystemId(neighbor.neighborSystemId());
@@ -509,7 +509,7 @@
areaAddressTlv.addAddress(isisInterface.areaAddress());
l1L2HelloPdu.addTlv(areaAddressTlv);
Set<MacAddress> neighbors = isisInterface.neighbors();
- if (neighbors.size() > 0) {
+ if (!neighbors.isEmpty()) {
List<MacAddress> neighborMacs = new ArrayList<>();
for (MacAddress neighbor : neighbors) {
IsisNeighbor isisNeighbor = isisInterface.lookup(neighbor);
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
index 83462ee..01f52dc 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
@@ -115,10 +115,10 @@
try {
List<OspfProcess> ospfProcesses = OspfConfigUtil.processes(processesNode);
//if there is interface details then update configuration
- if (ospfProcesses.size() > 0 &&
- ospfProcesses.get(0).areas() != null && ospfProcesses.get(0).areas().size() > 0 &&
+ if (!ospfProcesses.isEmpty() &&
+ ospfProcesses.get(0).areas() != null && !ospfProcesses.get(0).areas().isEmpty() &&
ospfProcesses.get(0).areas().get(0) != null &&
- ospfProcesses.get(0).areas().get(0).ospfInterfaceList().size() > 0) {
+ !ospfProcesses.get(0).areas().get(0).ospfInterfaceList().isEmpty()) {
ctrl.updateConfig(ospfProcesses);
}
} catch (Exception e) {
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
index 1d6ae23..e459afa 100644
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
@@ -66,6 +66,6 @@
ospfMessageList.add(message);
}
}
- return (ospfMessageList.size() > 0) ? ospfMessageList : null;
+ return (!ospfMessageList.isEmpty()) ? ospfMessageList : null;
}
}
\ No newline at end of file
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
index efaae8a..d5fed14 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -356,7 +356,7 @@
OvsdbSet setPorts = (OvsdbSet) bridge.getPortsColumn().data();
@SuppressWarnings("unchecked")
Set<Uuid> ports = setPorts.set();
- if (ports == null || ports.size() == 0) {
+ if (ports == null || ports.isEmpty()) {
log.warn("The port uuid is null");
return null;
}
@@ -677,9 +677,9 @@
mirrorBuilder.externalIds(mirror.externalIds());
mirror = mirrorBuilder.build();
- if (mirror.monitorDstPorts().size() == 0 &&
- mirror.monitorSrcPorts().size() == 0 &&
- mirror.monitorVlans().size() == 0) {
+ if (mirror.monitorDstPorts().isEmpty() &&
+ mirror.monitorSrcPorts().isEmpty() &&
+ mirror.monitorVlans().isEmpty()) {
log.warn("Invalid monitoring data");
return false;
}
@@ -1332,7 +1332,7 @@
OvsdbSet datapathIdSet = (OvsdbSet) bridge.getDatapathIdColumn().data();
@SuppressWarnings("unchecked")
Set<String> datapathIds = datapathIdSet.set();
- if (datapathIds == null || datapathIds.size() == 0) {
+ if (datapathIds == null || datapathIds.isEmpty()) {
return null;
}
String datapathId = (String) datapathIds.toArray()[0];
@@ -1347,7 +1347,7 @@
OvsdbSet ofPortSet = (OvsdbSet) intf.getOpenFlowPortColumn().data();
@SuppressWarnings("unchecked")
Set<Integer> ofPorts = ofPortSet.set();
- if (ofPorts == null || ofPorts.size() <= 0) {
+ if (ofPorts == null || ofPorts.isEmpty()) {
log.debug("The ofport is null in {}", intf.getName());
return -1;
}
diff --git a/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java b/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java
index 04199e2..8258a74 100644
--- a/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java
+++ b/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java
@@ -342,7 +342,7 @@
OvsdbSet ofPortSet = (OvsdbSet) intf.getOpenFlowPortColumn().data();
@SuppressWarnings("unchecked")
Set<Integer> ofPorts = ofPortSet.set();
- while (ofPorts == null || ofPorts.size() <= 0) {
+ while (ofPorts == null || ofPorts.isEmpty()) {
log.debug("The ofport is null in {}", intf.getName());
return -1;
}
@@ -374,7 +374,7 @@
OvsdbSet dpidSet = (OvsdbSet) bridge.getDatapathIdColumn().data();
@SuppressWarnings("unchecked")
Set<String> dpids = dpidSet.set();
- if (dpids == null || dpids.size() == 0) {
+ if (dpids == null || dpids.isEmpty()) {
return 0;
}
return stringToLong((String) dpids.toArray()[0]);
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/BasicPceccHandler.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/BasicPceccHandler.java
index 90b8ea0..9d65a16 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/BasicPceccHandler.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/BasicPceccHandler.java
@@ -153,7 +153,7 @@
checkNotNull(pceStore, PCE_STORE_NULL);
List<Link> linkList = tunnel.path().links();
- if ((linkList != null) && (linkList.size() > 0)) {
+ if ((linkList != null) && (!linkList.isEmpty())) {
// Sequence through reverse order to push local labels into devices
// Generation of labels from egress to ingress
for (ListIterator<Link> iterator = linkList.listIterator(linkList.size()); iterator.hasPrevious();) {
@@ -161,7 +161,7 @@
DeviceId dstDeviceId = link.dst().deviceId();
DeviceId srcDeviceId = link.src().deviceId();
labelRscList = labelRsrcService.applyFromDevicePool(dstDeviceId, applyNum);
- if ((labelRscList != null) && (labelRscList.size() > 0)) {
+ if ((labelRscList != null) && (!labelRscList.isEmpty())) {
// Link label value is taken from destination device local pool.
// [X]OUT---link----IN[Y]OUT---link-----IN[Z] where X, Y and Z are nodes.
// Link label value is used as OUT and IN for both ends
@@ -228,7 +228,7 @@
boolean srcDeviceUpdated = false;
List<LspLocalLabelInfo> lspLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
- if ((lspLabelInfoList != null) && (lspLabelInfoList.size() > 0)) {
+ if ((lspLabelInfoList != null) && (!lspLabelInfoList.isEmpty())) {
for (int i = 0; i < lspLabelInfoList.size(); ++i) {
LspLocalLabelInfo lspLocalLabelInfo =
lspLabelInfoList.get(i);
@@ -299,7 +299,7 @@
Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create();
List<LspLocalLabelInfo> lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
- if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) {
+ if ((lspLocalLabelInfoList != null) && (!lspLocalLabelInfoList.isEmpty())) {
for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) {
LspLocalLabelInfo lspLocalLabelInfo = iterator.next();
DeviceId deviceId = lspLocalLabelInfo.deviceId();
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PceccSrTeBeHandler.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PceccSrTeBeHandler.java
index 88e3b14..c6dad5a 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PceccSrTeBeHandler.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PceccSrTeBeHandler.java
@@ -191,7 +191,7 @@
// The specificDeviceId is the new device and is not there in the pce store.
// So, first generate its label and configure label and its lsr-id to it.
Collection<LabelResource> result = labelRsrcService.applyFromGlobalPool(applyNum);
- if (result.size() > 0) {
+ if (!result.isEmpty()) {
// Only one element (label-id) to retrieve
Iterator<LabelResource> iterator = result.iterator();
DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator.next();
@@ -338,7 +338,7 @@
// Allocate adjacency label to a link from label manager.
// Take label from source device pool to allocate.
labelList = labelRsrcService.applyFromDevicePool(srcDeviceId, applyNum);
- if (labelList.size() <= 0) {
+ if (labelList.isEmpty()) {
log.error("Unable to allocate label to a device id {}.", srcDeviceId.toString());
return false;
}
@@ -427,7 +427,7 @@
// Label stack is linked list to make labels in order.
List<LabelResourceId> labelStack = new LinkedList<>();
List<Link> linkList = path.links();
- if ((linkList != null) && (linkList.size() > 0)) {
+ if ((linkList != null) && (!linkList.isEmpty())) {
// Path: [x] ---- [y] ---- [z]
// For other than last link, add only source[x] device label.
// For the last link, add both source[y] and destination[z] device labels.
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
index d34c80e..f567e8d 100644
--- a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
@@ -87,7 +87,7 @@
TreeMap<String, BgpPeerCfg> displayPeerTree = bgpCfg.getPeerTree();
Set<String> peerKey = displayPeerTree.keySet();
if (peer != null) {
- if (peerKey.size() > 0) {
+ if (!peerKey.isEmpty()) {
for (String peerIdKey : peerKey) {
bgpPeerCfg = displayPeerTree.get(peerIdKey);
bgpConnectPeer = bgpPeerCfg.connectPeer();
@@ -101,7 +101,7 @@
}
}
} else {
- if (peerKey.size() > 0) {
+ if (!peerKey.isEmpty()) {
for (String peerIdKey : peerKey) {
bgpPeerCfg = displayPeerTree.get(peerIdKey);
bgpConnectPeer = bgpPeerCfg.connectPeer();
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
index 2f129ba..4a70556 100644
--- a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
@@ -64,7 +64,7 @@
this.bgpController = get(BgpController.class);
Map<String, List<String>> activeSessionExceptionMap = bgpController.activeSessionMap();
activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
- if (activeSessionExceptionkeySet.size() > 0) {
+ if (!activeSessionExceptionkeySet.isEmpty()) {
if (peerId != null) {
if (activeSessionExceptionkeySet.contains(peerId)) {
for (String peerIdKey : activeSessionExceptionkeySet) {
@@ -76,7 +76,7 @@
}
} else {
activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
- if (activeSessionExceptionkeySet.size() > 0) {
+ if (!activeSessionExceptionkeySet.isEmpty()) {
for (String peerId : activeSessionExceptionkeySet) {
print("PeerId = %s, Exception = %s ", peerId, activeSessionExceptionMap.get(peerId));
}
@@ -93,7 +93,7 @@
this.bgpController = get(BgpController.class);
Map<String, List<String>> closedSessionExceptionMap = bgpController.closedSessionMap();
closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
- if (closedSessionExceptionKeySet.size() > 0) {
+ if (!closedSessionExceptionKeySet.isEmpty()) {
if (peerId != null) {
if (closedSessionExceptionKeySet.contains(peerId)) {
for (String peerIdKey : closedSessionExceptionKeySet) {
@@ -105,7 +105,7 @@
}
} else {
closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
- if (closedSessionExceptionKeySet.size() > 0) {
+ if (!closedSessionExceptionKeySet.isEmpty()) {
for (String peerId : closedSessionExceptionKeySet) {
print("PeerId = %s, Exception = %s", peerId, closedSessionExceptionMap.get(peerId));
}
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index c1e2843..9c3ca0f 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -713,7 +713,7 @@
*/
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port,
OpenFlowOpticalSwitch opsw) {
- checkArgument(port.getDesc().size() >= 1);
+ checkArgument(!port.getDesc().isEmpty());
// Minimally functional fixture. This needs to be fixed as we add better support.
PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
@@ -790,7 +790,7 @@
// Use the alias name if it's available
String name = port.getName();
List<OFCalientPortDescProp> props = port.getProperties();
- if (props != null && props.size() > 0) {
+ if (props != null && !props.isEmpty()) {
OFCalientPortDescPropOptical propOptical = (OFCalientPortDescPropOptical) props.get(0);
if (propOptical != null) {
name = propOptical.getInAlias();
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
index 44b839b..e63fa69 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
@@ -131,10 +131,10 @@
if (treatment.clearedDeferred()) {
instructions.add(factory().instructions().clearActions());
}
- if (immediateActions.size() > 0) {
+ if (!immediateActions.isEmpty()) {
instructions.add(factory().instructions().applyActions(immediateActions));
}
- if (deferredActions.size() > 0) {
+ if (!deferredActions.isEmpty()) {
instructions.add(factory().instructions().writeActions(deferredActions));
}
if (treatment.tableTransition() != null) {
@@ -172,13 +172,13 @@
List<OFInstruction> instructions = Lists.newLinkedList();
- if (immediateActions.size() > 0) {
+ if (!immediateActions.isEmpty()) {
instructions.add(factory().instructions().applyActions(immediateActions));
}
if (treatment.clearedDeferred()) {
instructions.add(factory().instructions().clearActions());
}
- if (deferredActions.size() > 0) {
+ if (!deferredActions.isEmpty()) {
instructions.add(factory().instructions().writeActions(deferredActions));
}
if (treatment.tableTransition() != null) {
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
index 1ba438d..58cf18e 100644
--- a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
@@ -119,7 +119,7 @@
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
// If this is a drop rule
- if (actions.size() == 0) {
+ if (actions.isEmpty()) {
builder.drop();
return builder.build();
}
diff --git a/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/MeterModBuilder.java b/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/MeterModBuilder.java
index 5d2a101..406337b 100644
--- a/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/MeterModBuilder.java
+++ b/providers/openflow/meter/src/main/java/org/onosproject/provider/of/meter/impl/MeterModBuilder.java
@@ -155,6 +155,6 @@
private void validate() {
checkNotNull(id, "id cannot be null");
checkNotNull(bands, "Must have bands");
- checkArgument(bands.size() > 0, "Must have at lease one band");
+ checkArgument(!bands.isEmpty(), "Must have at lease one band");
}
}
diff --git a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
index 420dd0c..f7407ec 100644
--- a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
+++ b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
@@ -93,7 +93,7 @@
pcepSessionKeySet = pcepSessionMap.keySet();
pcepSessionIdKeySet = pcepSessionIdMap.keySet();
if (peer != null) {
- if (pcepSessionKeySet.size() > 0) {
+ if (!pcepSessionKeySet.isEmpty()) {
if (pcepSessionKeySet.contains(peer)) {
for (String pcepSessionPeer : pcepSessionKeySet) {
if (pcepSessionPeer.equals(peer)) {
@@ -116,7 +116,7 @@
}
}
} else {
- if (pcepSessionKeySet.size() > 0) {
+ if (!pcepSessionKeySet.isEmpty()) {
for (String pcepSessionPeer : pcepSessionKeySet) {
for (String pcepSessionId : pcepSessionIdKeySet) {
if (pcepSessionId.equals(pcepSessionPeer)) {
@@ -143,7 +143,7 @@
this.pcepClientController = get(PcepClientController.class);
Map<String, List<String>> pcepSessionFailureReasonMap = pcepClientController.getPcepExceptions();
pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
- if (pcepSessionFailurekeySet.size() > 0) {
+ if (!pcepSessionFailurekeySet.isEmpty()) {
if (peer != null) {
if (pcepSessionFailurekeySet.contains(peer)) {
for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
@@ -158,7 +158,7 @@
} else {
pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
- if (pcepSessionFailurekeySet.size() > 0) {
+ if (!pcepSessionFailurekeySet.isEmpty()) {
for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
pcepSessionExceptions = pcepSessionFailureReasonMap.get(pcepSessionPeerId);
print("PeerId = %s, FailureReason = %s", pcepSessionPeerId, pcepSessionExceptions);
@@ -181,7 +181,7 @@
this.pcepClientController = get(PcepClientController.class);
Map<Integer, Integer> pcepErrorMsgMap = pcepClientController.getPcepErrorMsg();
pcepErrorMsgKey = pcepErrorMsgMap.keySet();
- if (pcepErrorMsgKey.size() > 0) {
+ if (!pcepErrorMsgKey.isEmpty()) {
for (Integer errorType : pcepErrorMsgKey) {
pcepErrorValue = pcepErrorMsgMap.get(errorType);
pcepErrorType = PcepErrorType.values()[errorType];
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
index 767d026..caa317d 100644
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
+++ b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
@@ -720,7 +720,7 @@
// Creates a path that leads through the given devices.
private Path createPath(List<PcepHopNodeDescription> hopList,
PathType pathtype, PathState pathState) {
- if (hopList == null || hopList.size() == 0) {
+ if (hopList == null || hopList.isEmpty()) {
return null;
}
List<Link> links = new ArrayList<>();
@@ -947,7 +947,7 @@
llSubObjects = createPcepPath(path);
}
- if (llSubObjects == null || llSubObjects.size() == 0) {
+ if (llSubObjects == null || llSubObjects.isEmpty()) {
log.error("There is no link information to create tunnel");
return null;
}
@@ -1053,7 +1053,7 @@
LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = createPcInitiatedLspReqList(tunnel, path,
pc, srpId);
- if (llPcInitiatedLspRequestList == null || llPcInitiatedLspRequestList.size() == 0) {
+ if (llPcInitiatedLspRequestList == null || llPcInitiatedLspRequestList.isEmpty()) {
log.error("Failed to create PcInitiatedLspRequestList");
return;
}
@@ -1735,7 +1735,7 @@
checkNotNull(eroObj);
List<Object> subObjList = new ArrayList<>();
LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
- if (0 == llSubObj.size()) {
+ if (llSubObj.isEmpty()) {
log.error("ERO in report message does not have hop information");
return new ArrayList<>();
}
diff --git a/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java b/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java
index 09735b4..c07b00a 100644
--- a/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java
+++ b/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java
@@ -58,7 +58,7 @@
DijkstraGraphSearch<V, E> dijkstraSearch = new DijkstraGraphSearch<>();
Set<Path<V, E>> dijkstraResults = dijkstraSearch.search(originalGraph, src, dst, modifiedWeighter, 1).paths();
//Checks if the dst was reachable
- if (dijkstraResults.size() == 0) {
+ if (dijkstraResults.isEmpty()) {
log.warn("No path was found.");
return result;
}
@@ -84,7 +84,7 @@
}
dijkstraResults = dijkstraSearch.search(originalGraph, spurNode, dst, modifiedWeighter, 1).paths();
- if (dijkstraResults.size() != 0) {
+ if (!dijkstraResults.isEmpty()) {
Path<V, E> spurPath = dijkstraResults.iterator().next();
List<E> totalPath = new ArrayList<>(rootPathEdgeList);
spurPath.edges().forEach(e -> totalPath.add(e));
diff --git a/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java b/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java
index e90b9f0..5ac35a0 100644
--- a/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java
+++ b/utils/misc/src/main/java/org/onlab/graph/SrlgGraphSearch.java
@@ -184,7 +184,7 @@
public double fitness() {
Set<Path<V, E>> paths1 = findShortestPathFromSubset(subset).paths();
Set<Path<V, E>> paths2 = findShortestPathFromSubset(not).paths();
- if (paths1.size() == 0 || paths2.size() == 0) {
+ if (paths1.isEmpty() || paths2.isEmpty()) {
return INF;
}
return paths1.iterator().next().cost() + paths2.iterator().next().cost();
diff --git a/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java b/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java
index f3d0e62..f517d5a 100644
--- a/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java
+++ b/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java
@@ -56,7 +56,7 @@
//choose an arbitrary shortest path to run Suurballe on
Path<V, E> shortPath = null;
- if (firstDijkstraS.paths().size() == 0) {
+ if (firstDijkstraS.paths().isEmpty()) {
return firstDijkstraS;
}
@@ -88,7 +88,7 @@
.search(gt, src, dst, modified, ALL_PATHS);
Path<V, E> residualShortPath = null;
- if (secondDijkstra.paths().size() == 0) {
+ if (secondDijkstra.paths().isEmpty()) {
result.dpps.add(new DisjointPathPair<>(shortPath, null));
continue;
}
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java
index 39c9dd3..29291cd 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/NetworkConfigWebResource.java
@@ -204,7 +204,7 @@
errorMsgs.addAll(consumeJson(service, (ObjectNode) root.path(sk),
service.getSubjectFactory(sk)));
});
- if (errorMsgs.size() > 0) {
+ if (!errorMsgs.isEmpty()) {
return Response.status(MULTI_STATUS_RESPONE).entity(produceErrorJson(errorMsgs)).build();
}
return Response.ok().build();
@@ -227,7 +227,7 @@
NetworkConfigService service = get(NetworkConfigService.class);
ObjectNode root = (ObjectNode) mapper().readTree(request);
List<String> errorMsgs = consumeJson(service, root, service.getSubjectFactory(subjectClassKey));
- if (errorMsgs.size() > 0) {
+ if (!errorMsgs.isEmpty()) {
return Response.status(MULTI_STATUS_RESPONE).entity(produceErrorJson(errorMsgs)).build();
}
return Response.ok().build();
@@ -254,7 +254,7 @@
List<String> errorMsgs = consumeSubjectJson(service, root,
service.getSubjectFactory(subjectClassKey).createSubject(subjectKey),
subjectClassKey);
- if (errorMsgs.size() > 0) {
+ if (!errorMsgs.isEmpty()) {
return Response.status(MULTI_STATUS_RESPONE).entity(produceErrorJson(errorMsgs)).build();
}
return Response.ok().build();