Fixup Augmentable and Identifiable methods changing
[openflowplugin.git] / applications / bulk-o-matic / src / main / java / org / opendaylight / openflowplugin / applications / bulk / o / matic / BulkOMaticUtils.java
index edcaa4decb601e8c0911d423a9c18e8915f60506..60114cf99e6a74fd068a69d12dd9690f192cf6bd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Ericsson Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Ericsson Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.openflowplugin.applications.bulk.o.matic;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
@@ -28,24 +28,27 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class BulkOMaticUtils {
+public final class BulkOMaticUtils {
 
-    public final static int DEFUALT_STATUS = FlowCounter.OperationStatus.INIT.status();
-    public final static int DEFAULT_FLOW_COUNT = 0;
-    public final static long DEFAULT_COMPLETION_TIME = 0;
-    public final static String DEFAULT_UNITS = "ns";
-    public final static String DEVICE_TYPE_PREFIX = "openflow:";
+    public static final int DEFUALT_STATUS = FlowCounter.OperationStatus.INIT.status();
+    public static final int DEFAULT_FLOW_COUNT = 0;
+    public static final int DEFAULT_TABLE_COUNT = 0;
+    public static final long DEFAULT_COMPLETION_TIME = 0;
+    public static final String DEFAULT_UNITS = "ns";
+    public static final String DEVICE_TYPE_PREFIX = "openflow:";
 
-    public static String ipIntToStr (int k) {
-        return new StringBuilder().append(((k >> 24) & 0xFF)).append(".")
-                .append(((k >> 16) & 0xFF)).append(".")
-                .append(((k >> 8) & 0xFF)).append(".")
-                .append((k & 0xFF)).append("/32").toString();
+    private BulkOMaticUtils() {
     }
 
-    public static Match getMatch(final Integer sourceIp){
-        Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(
-                new Ipv4Prefix(ipIntToStr(sourceIp))).build();
+    public static String ipIntToStr(int number) {
+        return new StringBuilder().append(number >> 24 & 0xFF).append(".")
+                .append(number >> 16 & 0xFF).append(".")
+                .append(number >> 8 & 0xFF).append(".")
+                .append(number & 0xFF).append("/32").toString();
+    }
+
+    public static Match getMatch(final int sourceIp) {
+        Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build();
         MatchBuilder matchBuilder = new MatchBuilder();
         matchBuilder.setLayer3Match(ipv4Match);
         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
@@ -56,36 +59,28 @@ public class BulkOMaticUtils {
         return matchBuilder.build();
     }
 
-    public static Flow buildFlow(Short tableId, String flowId, Match match){
+    public static Flow buildFlow(Short tableId, String flowId, Match match) {
         FlowBuilder flowBuilder = new FlowBuilder();
-        flowBuilder.setKey(new FlowKey(new FlowId(flowId)));
+        flowBuilder.withKey(new FlowKey(new FlowId(flowId)));
         flowBuilder.setTableId(tableId);
         flowBuilder.setMatch(match);
         return flowBuilder.build();
     }
 
     public static InstanceIdentifier<Flow> getFlowInstanceIdentifier(Short tableId, String flowId, String dpId) {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class,
-                new NodeKey(new NodeId(dpId)))
-                .augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(tableId))
+        return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId)))
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId))
                 .child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow.class,
                         new FlowKey(new FlowId(flowId)));
     }
 
-    public static InstanceIdentifier<Node> getFlowCapableNodeId(String dpId){
-        return InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, new NodeKey(new NodeId(dpId)))
-                .build();
+    public static InstanceIdentifier<Node> getFlowCapableNodeId(String dpId) {
+        return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId))).build();
     }
 
     public static InstanceIdentifier<Table> getTableId(Short tableId, String dpId) {
-        return InstanceIdentifier.builder(Nodes.class)
-                .child(Node.class, new NodeKey(new NodeId(dpId)))
-                .augmentation(FlowCapableNode.class)
-                .child(Table.class, new TableKey(tableId))
-                .build();
-
+        return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId)))
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)).build();
     }
 
     public static InstanceIdentifier<Flow> getFlowId(final InstanceIdentifier<Table> tablePath, final String flowId) {