summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/websocketmanager/model
diff options
context:
space:
mode:
authorMichael DÜrre <michael.duerre@highstreet-technologies.com>2021-08-24 06:16:11 +0200
committerMichael DÜrre <michael.duerre@highstreet-technologies.com>2021-08-24 06:17:47 +0200
commitc8f7e3f376992b202ba26464b9b329d6c4b2821d (patch)
treec61507b22b28ccc536485a8bf291826d0461b031 /sdnr/wt/websocketmanager/model
parent2a55fbf61c4450bfc2bb3f90b060c3aa65af91f3 (diff)
fix some sdnr sonar bugs
sonar fixes for some sdnr components Issue-ID: SDNC-1590 Change-Id: I02e44b6f5477bcd0490c3499caf20228eb9772ed Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/websocketmanager/model')
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/ReducedSchemaInfo.java19
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java22
-rw-r--r--sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/Scope.java2
3 files changed, 30 insertions, 13 deletions
diff --git a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/ReducedSchemaInfo.java b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/ReducedSchemaInfo.java
index f6e6c5d0d..9bc51d4c5 100644
--- a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/ReducedSchemaInfo.java
+++ b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/ReducedSchemaInfo.java
@@ -21,7 +21,9 @@
*/
package org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data;
+import java.util.Optional;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
public class ReducedSchemaInfo {
private String namespace;
@@ -34,14 +36,23 @@ public class ReducedSchemaInfo {
public ReducedSchemaInfo(QName qname) {
this.namespace = qname.getNamespace().toString();
- this.revision = qname.getRevision().isPresent() ? qname.getRevision().get().toString() : null;
+ Optional<Revision> orev = qname.getRevision();
+ this.revision = orev.isPresent() ? orev.get().toString() : null;
this.type = qname.getLocalName();
}
public boolean equals(QName obj) {
- return this.namespace.equals(obj.getNamespace().toString()) && this.type.equals(obj.getLocalName())
- && ((this.revision == null && obj.getRevision().isEmpty())
- || (this.revision.equals(obj.getRevision().get().toString())));
+ Optional<Revision> orev = obj.getRevision();
+ if (this.namespace.equals(obj.getNamespace().toString()) && this.type.equals(obj.getLocalName())) {
+ if (this.revision == null) {
+ return orev.isEmpty();
+ } else if (orev.isEmpty()) {
+ return false;
+ } else {
+ return orev.get().toString().equals(this.revision);
+ }
+ }
+ return false;
}
public String getNamespace() {
diff --git a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java
index b920ffe71..032659c47 100644
--- a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java
+++ b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/SchemaInfo.java
@@ -24,7 +24,9 @@ package org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
public class SchemaInfo {
private String namespace;
@@ -33,14 +35,18 @@ public class SchemaInfo {
public SchemaInfo() {}
-
-
public SchemaInfo(QName qname) {
- this(qname.getNamespace().toString(),
- qname.getRevision().isPresent() ? qname.getRevision().get().toString() : null, new ArrayList<>());
+ this(qname.getNamespace().toString(), getRevision(qname), new ArrayList<>());
this.notification.add(qname.getLocalName());
}
+ private static String getRevision(QName qname) {
+ Optional<Revision> orev = qname.getRevision();
+ return orev.isPresent() ? orev.get().toString() : null;
+ }
+
+
+
public SchemaInfo(String namespace, String revision, List<String> notifications) {
this.namespace = namespace;
this.revision = revision;
@@ -78,8 +84,7 @@ public class SchemaInfo {
*/
@JsonIgnore
public boolean isValid() {
- return this.namespace != null
- && (this.notification == null || (this.notification != null && !this.notification.isEmpty()));
+ return this.namespace != null && (this.notification == null || !this.notification.isEmpty());
}
/**
@@ -95,7 +100,7 @@ public class SchemaInfo {
return true;
}
//if namespace does not match => false
- if (!this.namespace.equals(schema.getNamespace().toString())) {
+ if (!this.namespace.equals(schema.getNamespace())) {
return false;
}
//if revision of scope is set and it does not match and is not '*' => false
@@ -120,8 +125,9 @@ public class SchemaInfo {
if (this.revision == null && qname.getRevision().isEmpty()) {
return true;
}
+ Optional<Revision> orev = qname.getRevision();
if (this.revision != null) {
- return this.revision.equals(qname.getRevision().isEmpty() ? null : qname.getRevision().get().toString());
+ return this.revision.equals(orev.isEmpty() ? null : orev.get().toString());
}
return false;
}
diff --git a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/Scope.java b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/Scope.java
index b30aed1a6..4368ed550 100644
--- a/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/Scope.java
+++ b/sdnr/wt/websocketmanager/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager/model/data/Scope.java
@@ -112,7 +112,7 @@ public class Scope {
public static List<Scope> createList(String nodeId, List<QName> qnames) {
List<Scope> scopes = new ArrayList<>();
- Optional<Scope> listElem = null;
+ Optional<Scope> listElem;
for (QName qname : qnames) {
listElem = scopes.stream().filter(e -> e.schema != null && e.schema.equalsNamespaceAndRevision(qname))
.findFirst();