Fix a bug when creating FlowId and FlowBatchId from hex string:

 * Added static methods FlowId.valueOf(String) and FlowBatchId.valueOf(String)
   Implementation-wise, those methods are practically same as
   IntentId.valueOf(String)

 * Used the above methods as appropriate.

This fixes an exception that for some reason only occasionally shows-up
in logs of some of the unit tests, and also does not break those tests.

Also, make the change to accept hex strings starting with either 0x or 0X.

Change-Id: Iaaee529866deb1a89ccc3f306901672f25be6326
diff --git a/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java b/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
index 3bf9a30..c72d7cb 100644
--- a/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
+++ b/src/main/java/net/onrc/onos/api/flowmanager/FlowId.java
@@ -13,9 +13,25 @@
  */
 @Immutable
 public final class FlowId implements BatchOperationTarget {
+    private static final int DEC = 10;
+    private static final int HEX = 16;
+
     private final long id;
 
     /**
+     * Creates a flow identifier from the specified string representation.
+     *
+     * @param value long value
+     * @return flow identifier
+     */
+    public static FlowId valueOf(String value) {
+        long id = value.toLowerCase().startsWith("0x")
+                ? Long.parseLong(value.substring(2), HEX)
+                : Long.parseLong(value, DEC);
+        return new FlowId(id);
+    }
+
+    /**
      * Default constructor for Kryo deserialization.
      */
     @Deprecated