001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014 package org.apache.tapestry.enhance;
015
016
017 /**
018 * A representation of a {@link java.lang.reflect.Method}, identifying the name, return type,
019 * parameter types and exception types. Actual Method objects are tied to a particular class, and
020 * don't compare well with other otherwise identical Methods from other classes or interface;
021 * MethodSignatures are distinct from classes and compare well.
022 * <p>
023 * Because the intended purpose is to compare methods from interfaces (which are always public and
024 * abstract) we don't bother to actually track the modifiers. In addition, at this time,
025 * MethodSignature <em>does not distinguish between instance and static
026 * methods</em>.
027 */
028 public interface MethodSignature
029 {
030 /**
031 * Returns the exceptions for this method. Caution: do not modify the returned array. May return
032 * null.
033 */
034 Class[] getExceptionTypes();
035
036 /**
037 * The name of the method.
038 * @return method name
039 */
040 String getName();
041
042 /**
043 * Returns the parameter types for this method. May return null. Caution: do not modify the
044 * returned array.
045 */
046 Class[] getParameterTypes();
047
048 /**
049 * Method return type.
050 *
051 * @return The return type of the method.
052 */
053 Class getReturnType();
054
055 /**
056 * Returns a string consisting of the name of the method and its parameter values. This is
057 * similar to {@link #toString()}, but omits the return type and information about thrown
058 * exceptions. A unique id is used by MethodIterator to identify overlapping methods
059 * (methods with the same name but different thrown exceptions).
060 *
061 */
062 String getUniqueId();
063
064 /**
065 * Returns true if this signature has the same return type, name and parameters types as the
066 * method signature passed in, and this signatures exceptions "trump" (are the same as, or
067 * super-implementations of, all exceptions thrown by the other method signature).
068 *
069 */
070
071 boolean isOverridingSignatureOf(MethodSignature ms);
072
073 /**
074 * If the method definition has generic parameters or return types it
075 * is expected that this will return true.
076 *
077 * @return True if this is a generics based method, false otherwise.
078 */
079 boolean isGeneric();
080 }