java_gen: beautify toString output of OFMatch
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();
+ }