All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.xbean.kernel.ServiceName Maven / Gradle / Ivy

The newest version!
/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.xbean.kernel;

/**
 * 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()});
 * 
* * @author Dain Sundstrom * @version $Id$ * @since 2.0 */ public interface ServiceName { /** * 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;
     * }
     * 
* * @return the hash code */ int hashCode(); /** * 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));
     * }
     * 
* * @param object some object * @return true if the object is equivalent to this service name; false otherwise */ boolean equals(Object object); /** * A service name should return a string from toString that can be used in a String constructor. * * @return the connonical form of this name */ String toString(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy