org.apache.xbean.kernel
Interface ServiceName

All Known Implementing Classes:
StringServiceName

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()});
 

Since:
2.0
Author:
Dain Sundstrom

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

hashCode

int hashCode()
A service name must properly implement hashCode. For example,

 public int hashCode() {
     int result = 17;
     result = 37 * result + integer;
     result = 37 * result + (object == null ? 0 : object.hashCode());
     return result;
 }
 

Overrides:
hashCode in class Object
Returns:
the hash code

equals

boolean equals(Object object)
A service name must property implement equals. For example,

 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));
 }
 

Overrides:
equals in class Object
Parameters:
object - some object
Returns:
true if the object is equivalent to this service name; false otherwise

toString

String toString()
A service name should return a string from toString that can be used in a String constructor.

Overrides:
toString in class Object
Returns:
the connonical form of this name


Copyright © 2005-2008 Apache Software Foundation. All Rights Reserved.