added treatment support and conversion to an instruction

moved to meter api to onos-api

Change-Id: I0504f06fdc503953fa7696224d97edda43596d6e
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index 3cacfa5..cd9ec96 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -34,6 +34,7 @@
 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction;
 import org.onosproject.net.flow.instructions.L4ModificationInstruction.L4SubType;
 import org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction;
+import org.onosproject.net.meter.MeterId;
 
 import java.util.Objects;
 
@@ -81,6 +82,11 @@
         return new GroupInstruction(groupId);
     }
 
+    public static MeterInstruction meterTraffic(final MeterId meterId) {
+        checkNotNull(meterId, "meter id cannot be null");
+        return new MeterInstruction(meterId);
+    }
+
     /**
      * Creates a l0 modification.
      *
@@ -528,6 +534,50 @@
     }
 
     /**
+     * A meter instruction.
+     */
+    public static final class MeterInstruction implements Instruction {
+        private final MeterId meterId;
+
+        private MeterInstruction(MeterId meterId) {
+            this.meterId = meterId;
+        }
+
+        public MeterId meterId() {
+            return meterId;
+        }
+
+        @Override
+        public Type type() {
+            return Type.METER;
+        }
+
+        @Override
+        public String toString() {
+            return toStringHelper(type().toString())
+                    .add("meter ID", meterId.id()).toString();
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type().ordinal(), meterId);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof MeterInstruction) {
+                MeterInstruction that = (MeterInstruction) obj;
+                return Objects.equals(meterId, that.meterId);
+
+            }
+            return false;
+        }
+    }
+
+    /**
      *  Transition instruction.
      */
     public static class TableTypeTransition implements Instruction {