small fixes to ethtype pattern

Change-Id: Ic58c426821952f66aa21bc828d36fd4f83d8da0d
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 500ac1c..9703e1c 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
@@ -15,7 +15,7 @@
  */
 package org.onosproject.net.flow.instructions;
 
-import org.onlab.packet.Ethernet;
+import org.onlab.packet.EthType;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
@@ -265,7 +265,7 @@
     public static Instruction pushMpls() {
         return new L2ModificationInstruction.PushHeaderInstructions(
                 L2ModificationInstruction.L2SubType.MPLS_PUSH,
-                                          Ethernet.MPLS_UNICAST);
+                                          EthType.EtherType.MPLS_UNICAST.ethType());
     }
 
     /**
@@ -276,7 +276,7 @@
     public static Instruction popMpls() {
         return new L2ModificationInstruction.PushHeaderInstructions(
                 L2ModificationInstruction.L2SubType.MPLS_POP,
-                                          Ethernet.MPLS_UNICAST);
+                EthType.EtherType.MPLS_UNICAST.ethType());
     }
 
     /**
@@ -285,9 +285,23 @@
      * @param etherType Ethernet type to set
      * @return a L2 modification.
      */
+    @Deprecated
     public static Instruction popMpls(int etherType) {
         checkNotNull(etherType, "Ethernet type cannot be null");
         return new L2ModificationInstruction.PushHeaderInstructions(
+                L2ModificationInstruction.L2SubType.MPLS_POP, new EthType(etherType));
+    }
+
+
+    /**
+     * Creates a pop MPLS header instruction with a particular ethertype.
+     *
+     * @param etherType Ethernet type to set
+     * @return a L2 modification.
+     */
+    public static Instruction popMpls(EthType etherType) {
+        checkNotNull(etherType, "Ethernet type cannot be null");
+        return new L2ModificationInstruction.PushHeaderInstructions(
                 L2ModificationInstruction.L2SubType.MPLS_POP, etherType);
     }
 
@@ -308,7 +322,8 @@
      */
     public static Instruction pushVlan() {
         return new L2ModificationInstruction.PushHeaderInstructions(
-                L2ModificationInstruction.L2SubType.VLAN_PUSH, Ethernet.TYPE_VLAN);
+                L2ModificationInstruction.L2SubType.VLAN_PUSH,
+                EthType.EtherType.VLAN.ethType());
     }
 
     /**
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
index b993848..2fd809f 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
@@ -15,6 +15,7 @@
  */
 package org.onosproject.net.flow.instructions;
 
+import org.onlab.packet.EthType;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
 import org.onlab.packet.VlanId;
@@ -145,16 +146,16 @@
     public static final class PushHeaderInstructions extends
             L2ModificationInstruction {
 
-        private static final int MASK = 0xffff;
-        private final L2SubType subtype;
-        private final int ethernetType; // Ethernet type value: 16 bits
 
-        PushHeaderInstructions(L2SubType subType, int ethernetType) {
+        private final L2SubType subtype;
+        private final EthType ethernetType; // Ethernet type value: 16 bits
+
+        PushHeaderInstructions(L2SubType subType, EthType ethernetType) {
             this.subtype = subType;
-            this.ethernetType = ethernetType & MASK;
+            this.ethernetType = ethernetType;
         }
 
-        public int ethernetType() {
+        public EthType ethernetType() {
             return ethernetType;
         }
 
@@ -166,7 +167,7 @@
         @Override
         public String toString() {
             return toStringHelper(subtype().toString())
-                    .add("ethernetType", String.format("0x%04x", ethernetType()))
+                    .add("ethernetType", ethernetType())
                     .toString();
         }