java_gen: OFOxm: add 'canonical' virtual attribute, test

This enables OFOxm objects to return a 'canonical' representation,
where trivial masks (all-0, all-1) are converted to the main
representation.
diff --git a/java_gen/templates/custom/OFOxm_getCanonical.java b/java_gen/templates/custom/OFOxm_getCanonical.java
new file mode 100644
index 0000000..6681870
--- /dev/null
+++ b/java_gen/templates/custom/OFOxm_getCanonical.java
@@ -0,0 +1,17 @@
+//:: import re
+    public ${prop.java_type.public_type} getCanonical() {
+        //:: if not msg.member_by_name("masked").value == "true":
+        // exact match OXM is always canonical
+        return this;
+        //:: else:
+        //:: mask_type = msg.member_by_name("mask").java_type.public_type
+        if (${mask_type}.NO_MASK.equals(mask)) {
+            //:: unmasked = re.sub(r'(.*)Masked(Ver.*)', r'\1\2', msg.name)
+            return new ${unmasked}(value);
+        } else if(${mask_type}.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+        //:: #endif
+    }