|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ServiceName
The immutable unique name of a service. A proper implementation of ServiceName must have a correct implementation of equals and hashCode. A ServiceName should have one constructor that takes a single String and the toString method should return a String that can be used in the String constructor. This means the following code should work:
Constructor constructor = serviceName.getClass().getConstructor(new Class[] {String.class});
ServiceName name = constructor.newInstance(new Object[] {serviceName.toString()});
| Method Summary | |
|---|---|
boolean |
equals(Object object)
A service name must property implement equals. |
int |
hashCode()
A service name must properly implement hashCode. |
String |
toString()
A service name should return a string from toString that can be used in a String constructor. |
| Method Detail |
|---|
int hashCode()
public int hashCode() {
int result = 17;
result = 37 * result + integer;
result = 37 * result + (object == null ? 0 : object.hashCode());
return result;
}
hashCode in class Objectboolean equals(Object object)
public boolean equals(Object obj) {
if (!(obj instanceof MyServiceName)) {
return false;
}
MyServiceName name = (MyServiceName) obj;
return integer == name.integer &&
(object == null ? name.object == null : object.equals(name.object));
}
equals in class Objectobject - some object
String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||