Cleanup and rearrangements in Match structure and fields.
1. Added full documentation for the Match interface
2. Added Builder into Match interface and removed the separate class
3. Added ability to declare field prerequisites in the MatchField class and then check that they are
met using a given Match object
4. Fixed some small issues in value types and added a value type for Metadata
diff --git a/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Prerequisite.java b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Prerequisite.java
new file mode 100644
index 0000000..f518925
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/openflow/protocol/match/Prerequisite.java
@@ -0,0 +1,44 @@
+package org.openflow.protocol.match;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.openflow.types.OFValueType;
+
+public class Prerequisite<T extends OFValueType<T>> {
+ private MatchField<T> field;
+ private Set<OFValueType<T>> values;
+ private boolean any;
+
+ public Prerequisite(MatchField<T> field, OFValueType<T>... values) {
+ this.values = new HashSet<OFValueType<T>>();
+ this.field = field;
+ if (values == null || values.length == 0) {
+ this.any = true;
+ } else {
+ this.any = false;
+ for (OFValueType<T> value : values) {
+ this.values.add(value);
+ }
+ }
+ }
+
+ /**
+ * Returns true if this prerequisite is satisfied by the given match object.
+ *
+ * @param match Match object
+ * @return true iff prerequisite is satisfied.
+ */
+ public boolean isStaisfied(Match match) {
+ OFValueType<T> res = match.get(this.field);
+ if (res == null)
+ return false;
+ if (this.any)
+ return true;
+ if (this.values.contains(res)) {
+ return true;
+ }
+ return false;
+ }
+
+}