View Javadoc

1   package org.sourceforge.jemm.database.components;
2   
3   import org.sourceforge.jemm.database.ClientThreadId;
4   import org.sourceforge.jemm.types.ID;
5   
6   /**
7    * A class representing a client thread id and ID relationship.
8    *
9    * @author Rory Graves
10   */
11  public class ClientThreadIdRef {
12  	private final ClientThreadId clientThread;
13  	private final ID id;
14  	
15  	/**
16  	 * Create a ClientThreadIdRef with the given thread and id.
17  	 * @param clientThread The client thread id
18  	 * @param id The object id.
19  	 */
20  	public ClientThreadIdRef(ClientThreadId clientThread,ID id) {
21  	    if(clientThread == null)
22  	        throw new IllegalArgumentException("client thread may not be null");
23  		if(id == null)
24              throw new IllegalArgumentException("id may not be null");
25  
26  		this.clientThread = clientThread;
27  		this.id = id;
28  	}
29  
30  	@Override public int hashCode() {
31  		final int prime = 31;
32  		int result = 1;
33          result = prime * clientThread.hashCode();
34          result = prime * id.hashCode();
35  		return result;
36  	}
37  
38  	@Override
39  	public boolean equals(Object obj) {
40  		if (this == obj)
41  			return true;
42  		if (obj == null)
43  			return false;
44  		if (getClass() != obj.getClass())
45  			return false;
46  		ClientThreadIdRef other = (ClientThreadIdRef) obj;
47          if(!clientThread.equals(other.clientThread))
48                  return false;
49          if(!id.equals(other.id))
50                  return false;
51  		return true;
52  	}
53  
54      /** Returns the first value in the tuple
55       * @return the first value in the tuple
56       */
57      public ClientThreadId getClientThread() {
58          return clientThread;
59      }
60  
61      /**  Returns the second value in the tuple
62       * @return the second value in the tuple
63       */
64      public ID getID() {
65          return id;
66      }
67  }