X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=networkmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Flisteners%2FAlarmNotificationListener221.java;h=8c3fb9043970803bec456de0adbb995f2a2b96a8;hb=d122f702163dae63be448259ab108fdcac29a5ac;hp=713c98c01c99147fb2ef9efd14bf9f5cdde13731;hpb=17af6c5fc36b813484b416b26c59a0e3f3056341;p=transportpce.git diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/AlarmNotificationListener221.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/AlarmNotificationListener221.java index 713c98c01..8c3fb9043 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/AlarmNotificationListener221.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/AlarmNotificationListener221.java @@ -69,17 +69,12 @@ public class AlarmNotificationListener221 implements OrgOpenroadmAlarmListener { } catch (InterruptedException | ExecutionException ex) { LOG.warn("Exception thrown while reading Logical Connection Point value", ex); } - StringBuilder sb = new StringBuilder(notification.getResource().getDevice().getNodeId().getValue()) - .append(PIPE); - sb.append(buildCause(notification.getProbableCause())); - sb.append(notification.getId() != null ? notification.getId() : "").append(PIPE) - .append(notification.getRaiseTime() != null ? notification.getRaiseTime().toString() : "").append(PIPE) - .append(notification.getSeverity() != null ? notification.getSeverity().getName() : "").append(PIPE) - .append(notification.getCircuitId() != null ? notification.getCircuitId() : "").append(PIPE); + String message = String.join(PIPE,notification.getResource().getDevice().getNodeId().getValue(), + buildCause(notification.getProbableCause()),notification.getId() != null ? notification.getId() : "", + notification.getRaiseTime() != null ? notification.getRaiseTime().toString() : "", + notification.getSeverity() != null ? notification.getSeverity().getName() : "", + notification.getCircuitId() != null ? notification.getCircuitId() : "", buildType(notification)); - sb.append(buildType(notification)); - - String message = sb.toString(); Nodes build = new NodesBuilder().setNodeId(notification.getResource().getDevice().getNodeId().getValue()) .build(); if (allNodeList.contains(build)) { @@ -90,16 +85,15 @@ public class AlarmNotificationListener221 implements OrgOpenroadmAlarmListener { } private String buildCause(ProbableCause probableCause) { - StringBuilder sb = new StringBuilder(); if (probableCause == null) { return "||||"; } - sb.append((probableCause.getCause() != null) ? probableCause.getCause().getName() : "").append(PIPE) - .append((probableCause.getDirection() != null) ? probableCause.getDirection().getName() : "") - .append(PIPE).append((probableCause.getExtension() != null) ? probableCause.getExtension() : "") - .append(PIPE).append((probableCause.getLocation() != null) ? probableCause.getLocation().getName() : "") - .append(PIPE); - return sb.toString(); + String probableCauseStr = String.join(PIPE, + (probableCause.getCause() != null) ? probableCause.getCause().getName() : "", + (probableCause.getDirection() != null) ? probableCause.getDirection().getName() : "", + (probableCause.getExtension() != null) ? probableCause.getExtension() : "", + (probableCause.getLocation() != null) ? probableCause.getLocation().getName() : ""); + return probableCauseStr; } @SuppressWarnings("unchecked") @@ -207,11 +201,8 @@ public class AlarmNotificationListener221 implements OrgOpenroadmAlarmListener { default: LOG.warn("Unknown resource type {}", wantedResourceType); } - StringBuilder sb = new StringBuilder(circuitPack); - sb.append(PIPE).append(connection).append(PIPE).append(degree).append(PIPE).append(iface); - sb.append(PIPE).append(internalLink).append(PIPE).append(physicalLink).append(PIPE).append(service); - sb.append(PIPE).append(shelf).append(PIPE).append(sharedRiskGroup).append(PIPE).append(port); - sb.append(PIPE).append(portCircuitPack); - return sb.toString(); + String buildTyeStr = String.join(PIPE, circuitPack, connection, degree, iface, internalLink, physicalLink, + service, shelf, sharedRiskGroup, port, portCircuitPack); + return buildTyeStr; } }