/******************************************************************************* * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.wst.jsdt.core.dom; /** * A method binding represents a method or constructor of a class or interface. * Method bindings usually correspond directly to method or * constructor declarations found in the source code. * However, in certain cases of references to a generic method, * the method binding may correspond to a copy of a generic method * declaration with substitutions for the method's type parameters * (for these, getTypeArguments returns a non-empty * list, and either isParameterizedMethod or * isRawMethod returns true). * And in certain cases of references to a method declared in a * generic type, the method binding may correspond to a copy of a * method declaration with substitutions for the type's type * parameters (for these, getTypeArguments returns * an empty list, and both isParameterizedMethod and * isRawMethod return false). *

* This interface is not intended to be implemented by clients. *

* * @see ITypeBinding#getDeclaredMethods() * * Provisional API: This class/interface is part of an interim API that is still under development and expected to * change significantly before reaching stability. It is being made available at this early stage to solicit feedback * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken * (repeatedly) as the API evolves. */ public interface IFunctionBinding extends IBinding { /** * Returns whether this binding is for a constructor or a method. * * @return true if this is the binding for a constructor, * and false if this is the binding for a method */ public boolean isConstructor(); /** * Returns whether this binding is known to be a compiler-generated * default constructor. *

* This method returns false for: *

* * @return true if this is known to be the binding for a * compiler-generated default constructor, and false * otherwise * */ public boolean isDefaultConstructor(); /** * Returns the name of the method declared in this binding. The method name * is always a simple identifier. The name of a constructor is always the * same as the declared name of its declaring class. * * @return the name of this method, or the declared name of this * constructor's declaring class */ public String getName(); /** * Returns the type binding representing the class or interface * that declares this method or constructor. * * @return the binding of the class or interface that declares this method * or constructor */ public ITypeBinding getDeclaringClass(); /** * Returns the resolved default value of an annotation type member, * or null if the member has no default value, or if this * is not the binding for an annotation type member. *

* Resolved values are represented as follows (same as for * {@link IMemberValuePairBinding#getValue()}): *

* * @return the default value of this annotation type member, or null * if none or not applicable * */ public Object getDefaultValue(); /** * Returns a list of type bindings representing the formal parameter types, * in declaration order, of this method or constructor. Returns an array of * length 0 if this method or constructor does not takes any parameters. *

* Note that the binding for the last parameter type of a vararg method * declaration like void fun(Foo... args) is always for * an array type (i.e., Foo[]) reflecting the the way varargs * get compiled. However, the type binding obtained directly from * the SingleVariableDeclaration for the vararg parameter * is always for the type as written; i.e., the type binding for * Foo. *

*

* Note: The result does not include synthetic parameters introduced by * inner class emulation. *

* * @return a (possibly empty) list of type bindings for the formal * parameters of this method or constructor */ public ITypeBinding[] getParameterTypes(); /** * Returns the binding for the return type of this method. Returns the * special primitive void return type for constructors. * * @return the binding for the return type of this method, or the * void return type for constructors */ public ITypeBinding getReturnType(); /** * Returns the binding for the method declaration corresponding to this * method binding. For parameterized methods ({@link #isParameterizedMethod()}) * and raw methods ({@link #isRawMethod()}), this method returns the binding * for the corresponding generic method. For other method bindings, this * returns the same binding. * *

Note: The one notable exception is the method Object.getClass(), * which is declared to return Class<? extends Object>, but * when invoked its return type becomes Class<? extends * R>, where R is the compile type of * the receiver of the method invocation.

* * @return the method binding * */ public IFunctionBinding getMethodDeclaration(); /** * Returns whether this method's signature is a subsignature of the given method. * * @return true if this method's signature is a subsignature of the given method * */ public boolean isSubsignature(IFunctionBinding otherMethod); /** * Returns whether this is a variable arity method. *

* Note: Variable arity ("varargs") methods were added in JLS3. *

* * @return true if this is a variable arity method, * and false otherwise * */ public boolean isVarargs(); /** * Returns whether this method overrides the given method. * * @param method the method that is possibly overridden * @return true if this method overrides the given method, * and false otherwise * */ public boolean overrides(IFunctionBinding method); }