Define the new Intent Framework APIs (Intent Service)

- Define the base Intent class and sub-classes required in SDN-IP
- IntentService provides the APIs for application developers
- IntentExtensionService enables to define application specific intent types
- Provide event handling mechanism via IntentEventListener

This is for ONOS-1654.

Change-Id: Id1705f1fbc1acd4862b33fd9ab97aafe2e84a685
diff --git a/src/main/java/net/onrc/onos/api/newintent/IntentId.java b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
new file mode 100644
index 0000000..6d10b35
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/newintent/IntentId.java
@@ -0,0 +1,62 @@
+package net.onrc.onos.api.newintent;
+
+/**
+ * Intent identifier suitable as an external key.
+ *
+ * This class is immutable.
+ */
+public final class IntentId {
+
+    private static final int DEC = 10;
+    private static final int HEX = 16;
+
+    private final long id;
+
+    /**
+     * Creates an intent identifier from the specified string representation.
+     *
+     * @param value long value
+     * @return intent identifier
+     */
+    public static IntentId valueOf(String value) {
+        long id = value.startsWith("0x")
+                ? Long.parseLong(value.substring(2), HEX)
+                : Long.parseLong(value, DEC);
+        return new IntentId(id);
+    }
+
+
+    /**
+     * Constructs the ID corresponding to a given long value.
+     *
+     * @param id the underlying value of this ID
+     */
+    public IntentId(long id) {
+        this.id = id;
+    }
+
+    @Override
+    public int hashCode() {
+        return (int) (id ^ (id >>> 32));
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+
+        if (!(obj instanceof IntentId)) {
+            return false;
+        }
+
+        IntentId that = (IntentId) obj;
+        return this.id == that.id;
+    }
+
+    @Override
+    public String toString() {
+        return "0x" + Long.toHexString(id);
+    }
+
+}