1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.location;
20
21 import nl.toolforge.karma.core.boot.WorkingContext;
22 import nl.toolforge.karma.core.vc.AuthenticatorKey;
23
24 /***
25 * <code>BaseLocation</code> implements some generic <code>Location</code> functionality.
26 *
27 * @author D.A. Smedes
28 * @version $Id: BaseLocation.java,v 1.12 2004/11/03 20:54:15 asmedes Exp $
29 */
30 public abstract class BaseLocation implements Location {
31
32 private String id = null;
33 private LocationType type = null;
34 private WorkingContext workingContext = null;
35
36 /***
37 * Constructs a <code>Location</code> skeleton.
38 *
39 * @param id The unique identifier for the location. Cannot be null.
40 * @param type The type of the location. Cannot be null.
41 */
42 public BaseLocation(String id, LocationType type) {
43
44 if (id == null) {
45 throw new IllegalArgumentException("Location id must be set.");
46 }
47 if (type == null) {
48 throw new IllegalArgumentException("Location must be set.");
49 }
50 this.id = id;
51 this.type = type;
52 }
53
54 public final LocationType getType() {
55 return type;
56 }
57
58 public final String getId() {
59 return id;
60 }
61
62 public boolean equals(Object obj) {
63
64 if (obj instanceof BaseLocation) {
65 if (((BaseLocation) obj).getId().equals(getId())) {
66 return true;
67 }
68 }
69 return false;
70 }
71
72 public int hashCode() {
73 return getId().hashCode();
74 }
75
76
77
78 public final void setWorkingContext(WorkingContext workingContext) {
79 this.workingContext = workingContext;
80 }
81
82 public AuthenticatorKey getAuthenticatorKey() {
83 return new AuthenticatorKey(workingContext.getName(), getId());
84 }
85 }