01 package dk.deepthought.sidious.supportsystem;
02 
03 import net.jcip.annotations.Immutable;
04 
05 import org.apache.commons.logging.Log;
06 import org.apache.commons.logging.LogFactory;
07 
08 /**
09  * This class wraps the SuperLink Identifier for each sensor and set point in the system.
10  
11  @author Deepthought
12  
13  */
14 @Immutable
15 public final class SuperLinkID implements Comparable<SuperLinkID> {
16     /**
17      * Logger for this class
18      */
19     private static final Log logger = LogFactory.getLog(SuperLinkID.class);
20 
21     /**
22      * The string id.
23      */
24     private final String ID;
25 
26     /**
27      * Creates a new <code>SuperLinkID</code> object.
28      
29      @param id
30      *            the id string
31      */
32     public SuperLinkID(final String id) {
33         if ((id == null|| id.equals("")) {
34             logger.error("SuperLinkID(String id=" + id
35                     ") - Not valid initializing string value");
36             throw new IllegalArgumentException(
37                     "Not valid initializing string value=" + id);
38         }
39         ID = id;
40     }
41 
42     /* (non-Javadoc)
43      * @see java.lang.Object#equals(java.lang.Object)
44      */
45     @Override
46     public boolean equals(Object arg0) {
47         if (arg0 instanceof SuperLinkID) {
48             SuperLinkID sID = (SuperLinkIDarg0;
49             return ID.equals(sID.ID);
50         }
51         return false;
52     }
53 
54     /*
55      * (non-Javadoc)
56      
57      * @see java.lang.Object#toString()
58      */
59     @Override
60     public String toString() {
61         return ID;
62     }
63 
64     /*
65      * (non-Javadoc)
66      
67      * @see java.lang.Object#hashCode()
68      */
69     @Override
70     public int hashCode() {
71         final int PRIME = 31;
72         int result = 1;
73         result = PRIME * result + ((ID == null: ID.hashCode());
74         return result;
75     }
76 
77     /*
78      * (non-Javadoc)
79      
80      * @see java.lang.Comparable#compareTo(java.lang.Object)
81      */
82     public int compareTo(SuperLinkID other) {
83         return this.ID.compareTo(other.ID);
84     }
85 
86 }