Merge into master from pull request #184:
java_gen: beautify toString output of OFMatch (https://github.com/floodlight/loxigen/pull/184)
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.java b/java_gen/templates/custom/OFMatchV1Ver10.java
index 93c2ad0..8a24b2f 100644
--- a/java_gen/templates/custom/OFMatchV1Ver10.java
+++ b/java_gen/templates/custom/OFMatchV1Ver10.java
@@ -331,7 +331,7 @@
                 int dstCidrLen = getIpv4DstCidrMaskLen();
                 return dstCidrLen > 0 && dstCidrLen < 32;
             default:
-                throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+                return false;
         }
     }
 
diff --git a/java_gen/templates/custom/OFMatchV1Ver10_toString.java b/java_gen/templates/custom/OFMatchV1Ver10_toString.java
new file mode 100644
index 0000000..3b2783b
--- /dev/null
+++ b/java_gen/templates/custom/OFMatchV1Ver10_toString.java
@@ -0,0 +1 @@
+//:: include("custom/OFMatch_toString.java", msg=msg, has_parent=False)
diff --git a/java_gen/templates/custom/OFMatchV3Ver13_toString.java b/java_gen/templates/custom/OFMatchV3Ver13_toString.java
new file mode 100644
index 0000000..3b2783b
--- /dev/null
+++ b/java_gen/templates/custom/OFMatchV3Ver13_toString.java
@@ -0,0 +1 @@
+//:: include("custom/OFMatch_toString.java", msg=msg, has_parent=False)
diff --git a/java_gen/templates/custom/OFMatch_toString.java b/java_gen/templates/custom/OFMatch_toString.java
new file mode 100644
index 0000000..1eaf8a5
--- /dev/null
+++ b/java_gen/templates/custom/OFMatch_toString.java
@@ -0,0 +1,18 @@
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("${msg.name}(");
+        boolean first = true;
+        for(MatchField<?> field : getMatchFields()) {
+            if(first)
+                first = false;
+            else
+                b.append(", ");
+            String name = field.getName();
+            b.append(name).append('=').append(this.get(field));
+            if(isPartiallyMasked(field)) {
+                b.append('/').append(this.getMasked(field).getMask());
+            }
+        }
+        b.append(")");
+        return b.toString();
+    }
diff --git a/java_gen/templates/of_class.java b/java_gen/templates/of_class.java
index b35df1c..f1d72b2 100644
--- a/java_gen/templates/of_class.java
+++ b/java_gen/templates/of_class.java
@@ -363,6 +363,9 @@
         }
     }
 
+    //:: if os.path.exists("%s/custom/%s_toString.java" % (template_dir, msg.name)):
+    //:: include("custom/%s_toString.java" % msg.name, msg=msg, has_parent=False)
+    //:: else:
     @Override
     public String toString() {
         StringBuilder b = new StringBuilder("${msg.name}(");
@@ -375,7 +378,7 @@
         b.append(")");
         return b.toString();
     }
-
+    //:: #endif
 
     @Override
     public boolean equals(Object obj) {