java/HashValue: add+subtract, remove combineWithValue

Added arithmetic add and subtract operations to HashValue types. Also
removed the obsolete combineWithValue operation that had weird/broken
semantics.
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/HashValue.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/HashValue.java
index 1dd55d5..a656dab 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/HashValue.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/HashValue.java
@@ -17,6 +17,23 @@
      */
     int prefixBits(int numBits);
 
+    /** perform an arithmetic addition of this value and other. Wraps around on
+     * overflow of the defined word size.
+     *
+     * @param other
+     * @return this + other
+     */
+    H add(H other);
+
+    /**
+     * arithmetically substract the given 'other' value from this value.
+     * around on overflow.
+     *
+     * @param other
+     * @return this - other
+     */
+    H subtract(H other);
+
     /** @return the bitwise inverse of this value */
     H inverse();
 
@@ -28,27 +45,4 @@
 
     /** xor this value with another value value of the same type */
     H xor(H other);
-
-    /** calculate a combined hash value of this hash value (the <b>Key</b>) and the hash value
-     *  specified as a parameter (the <b>Value</b>).
-     *  <p>
-     *  The value is constructed as follows:
-     *  <ul>
-     *   <li>the first keyBits bits are taken only from the Key
-     *   <li>the other bits are taken from key xor value.
-     *  </ul>
-     *  The overall result looks like this:
-     *  <pre>
-     *  MSB                      LSB
-     *   +---------+--------------+
-     *   | key     | key ^ value  |
-     *   +---------+--------------+
-     *   |-keyBits-|
-     *  </pre>
-     *
-     * @param value - hash value to be compared with this value (the key)
-     * @param keyBits number of prefix bits that are just taken from key
-     * @return the combined value.
-     */
-    H combineWithValue(H value, int keyBits);
 }
\ No newline at end of file
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U128.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U128.java
index 35ef846..ba7d88a 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U128.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U128.java
@@ -123,15 +123,29 @@
     }
 
     @Override
+    public U128 add(U128 other) {
+        long newRaw2 = this.raw2 + other.raw2;
+        long newRaw1 = this.raw1 + other.raw1;
+        if (UnsignedLongs.compare(newRaw2, this.raw2) < 0 ||
+            UnsignedLongs.compare(newRaw2, other.raw2) < 0) {
+            // raw2 overflow
+            newRaw1+=1;
+        }
+        return U128.of(newRaw1, newRaw2);
+    }
+
+    @Override
+    public U128 subtract(U128 other) {
+        long newRaw2 = this.raw2 - other.raw2;
+        long newRaw1 = this.raw1 - other.raw1;
+        if (UnsignedLongs.compare(this.raw2, other.raw2) < 0) {
+            newRaw1 -= 1;
+        }
+        return U128.of(newRaw1, newRaw2);
+    }
+    @Override
     public int prefixBits(int numBits) {
         return HashValueUtils.prefixBits(this.raw1, numBits);
     }
 
-    @Override
-    public U128 combineWithValue(U128 value, int keyBits) {
-        return U128.of(
-                HashValueUtils.combineWithValue(this.raw1, value.raw1, Math.min(64, keyBits)),
-                HashValueUtils.combineWithValue(this.raw2, value.raw2, Math.max(0,keyBits-64))
-        );
-    }
 }
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
index 1353b42..dcd812d 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/U64.java
@@ -151,6 +151,16 @@
         return U64.of(raw ^ other.raw);
     }
 
+    @Override
+    public U64 add(U64 other) {
+        return U64.of(this.raw + other.raw);
+    }
+
+    @Override
+    public U64 subtract(U64 other) {
+        return U64.of(this.raw - other.raw);
+    }
+
     /** return the "numBits" highest-order bits of the hash.
      *  @param numBits number of higest-order bits to return [0-32].
      *  @return a numberic value of the 0-32 highest-order bits.
@@ -160,11 +170,6 @@
         return HashValueUtils.prefixBits(raw, numBits);
     }
 
-    @Override
-    public U64 combineWithValue(U64 value, int keyBits) {
-        return U64.of(HashValueUtils.combineWithValue(this.raw, value.raw, keyBits));
-    }
-
     public final static Reader READER = new Reader();
 
     private static class Reader implements OFMessageReader<U64> {
@@ -174,5 +179,4 @@
         }
     }
 
-
 }