Sonar fixes
Rule: Use isEmpty() to check whether the collection is empty or not.
Change-Id: Ib5ab56b2263623b297db56c5cac2c2ee80e12725
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.