ONOS-4380 Refactor AlarmId and Alarm construction and update

Change-Id: I0117afda723ba27aadb1db306f7ce15b666f102d
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
index db26a7e..bc84e8a 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmId.java
@@ -17,48 +17,64 @@
 
 import com.google.common.annotations.Beta;
 import org.onlab.util.Identifier;
+import org.onosproject.net.DeviceId;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Alarm identifier suitable as an external key.
  * <p>
  * This class is immutable.</p>
  */
 @Beta
-public final class AlarmId extends Identifier<Long> {
-
-    public static final AlarmId NONE = new AlarmId();
+public final class AlarmId extends Identifier<String> {
 
     /**
      * Instantiates a new Alarm id.
      *
-     * @param id the id
+     * @param id               the device id
+     * @param uniqueIdentifier the unique identifier of the Alarm on that device
      */
-    private AlarmId(long id) {
-        super(id);
-        checkArgument(id != 0L, "id must be non-zero");
-    }
-
-    private AlarmId() {
-        super(0L);
+    private AlarmId(DeviceId id, String uniqueIdentifier) {
+        super(id.toString() + ":" + uniqueIdentifier);
+        checkNotNull(id, "device id must not be null");
+        checkNotNull(uniqueIdentifier, "unique identifier must not be null");
+        checkArgument(!uniqueIdentifier.isEmpty(), "unique identifier must not be empty");
     }
 
     /**
-     * Creates an alarm identifier from the specified long representation.
+     * Instantiates a new Alarm id, primarly meant for lookup.
      *
-     * @param value long value
-     * @return intent identifier
+     * @param globallyUniqueIdentifier the globally unique identifier of the Alarm,
+     *                                 device Id + local unique identifier on the device
      */
-    public static AlarmId alarmId(long value) {
-        return new AlarmId(value);
+    private AlarmId(String globallyUniqueIdentifier) {
+        super(globallyUniqueIdentifier);
+        checkArgument(!globallyUniqueIdentifier.isEmpty(), "unique identifier must not be empty");
     }
 
     /**
-     * Returns the backing integer index.
+     * Creates an alarm identifier from the specified device id and
+     * unique identifier provided representation.
      *
-     * @return backing integer index
+     * @param id               device id
+     * @param uniqueIdentifier per device unique identifier of the alarm
+     * @return alarm identifier
      */
-    public long fingerprint() {
-        return identifier;
+    public static AlarmId alarmId(DeviceId id, String uniqueIdentifier) {
+        return new AlarmId(id, uniqueIdentifier);
     }
+
+    /**
+     * Creates an alarm identifier from the specified globally unique identifier.
+     *
+     * @param globallyUniqueIdentifier the globally unique identifier of the Alarm,
+     *                                 device Id + local unique identifier on the device
+     * @return alarm identifier
+     */
+    public static AlarmId alarmId(String globallyUniqueIdentifier) {
+        return new AlarmId(globallyUniqueIdentifier);
+    }
+
 }