Switch to MD-SAL APIs
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / compatibility / FlowStatisticsToNotificationTransformer.java
index bf843165716d7035606263991615538e6c93670a..5e78cddcc30d558521f995e874af1910d8b29238 100644 (file)
@@ -27,20 +27,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
 
 /**
- * pulled out flow stats to notification transformation
+ * Pulled out flow stats to notification transformation.
  */
-public class FlowStatisticsToNotificationTransformer {
+public final class FlowStatisticsToNotificationTransformer {
 
     private FlowStatisticsToNotificationTransformer() {
         // Hide implicit constructor
     }
 
     /**
+     * Transform to notification.
+     *
      * @param mpResult      raw multipart response from device
-     * @param deviceInfo   device state
+     * @param deviceInfo    device state
      * @param ofVersion     device version
-     * @param emulatedTxId
-     * @param convertorExecutor
+     * @param emulatedTxId  emulated transaction Id
+     * @param convertorExecutor convertor executor
      * @return notification containing flow stats
      */
     public static FlowsStatisticsUpdate transformToNotification(final List<MultipartReply> mpResult,
@@ -50,7 +52,7 @@ public class FlowStatisticsToNotificationTransformer {
                                                                 final ConvertorExecutor convertorExecutor) {
         final FlowStatsResponseConvertorData data = new FlowStatsResponseConvertorData(ofVersion.getVersion());
         data.setDatapathId(deviceInfo.getDatapathId());
-        data.setMatchPath(MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+        data.setMatchPath(MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
         final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
         final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
         notification.setId(deviceInfo.getNodeId());
@@ -67,9 +69,7 @@ public class FlowStatisticsToNotificationTransformer {
                     convertorExecutor.convert(replyBody.getFlowStats(), data);
 
 
-            if (outStatsItem.isPresent()) {
-                statsList.addAll(outStatsItem.get());
-            }
+            outStatsItem.ifPresent(statsList::addAll);
         }
 
         return notification.build();