First version after introduction of meaningful ids and Identifiable interface.
[xmlrouter] / common / src / main / java / org / wamblee / xmlrouter / common / Id.java
index f057b416ee8572570b018fd83594fa40869ffd63..1d31c8bab25115da24949ae4383326681a17f3d2 100644 (file)
@@ -25,28 +25,33 @@ package org.wamblee.xmlrouter.common;
  */
 public class Id<T> implements Comparable<Id<T>> {
 
-    private long id;
+    private String id;
 
     /**
      * Constructs the id.
      * 
      * @param aId
      *            Integer id.
+     * @throws NullPointerException
+     *             in case the id is null.
      */
-    public Id(long aId) {
+    public Id(String aId) {
+        if (aId == null) {
+            throw new NullPointerException("id is null");
+        }
         id = aId;
     }
 
     /**
      * @return The underlying id.
      */
-    public long getId() {
+    public String getId() {
         return id;
     }
 
     @Override
     public int hashCode() {
-        return ((Long) id).hashCode();
+        return id.hashCode();
     }
 
     @Override
@@ -62,11 +67,11 @@ public class Id<T> implements Comparable<Id<T>> {
 
     @Override
     public String toString() {
-        return id + "";
+        return id;
     }
 
     @Override
     public int compareTo(Id<T> aId) {
-        return ((Long) id).compareTo((Long) aId.getId());
+        return id.compareTo(aId.getId());
     }
 }