1 /* 2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.lang.model.element; 27 28 import java.util.List; 29 import javax.lang.model.type.*; 30 31 /** 32 * Represents a method, constructor, or initializer (static or 33 * instance) of a class or interface, including annotation type 34 * elements. 35 * 36 * @author Joseph D. Darcy 37 * @author Scott Seligman 38 * @author Peter von der Ahé 39 * @see ExecutableType 40 * @since 1.6 41 */ 42 public interface ExecutableElement extends Element, Parameterizable { 43 /** 44 * Returns the {@linkplain ExecutableType executable type} defined 45 * by this executable element. 46 * 47 * @return the type executable type defined by this executable element 48 */ 49 @Override 50 TypeMirror asType(); 51 52 /** 53 * Returns the formal type parameters of this executable 54 * in declaration order. 55 * 56 * @return the formal type parameters, or an empty list 57 * if there are none 58 */ 59 List<? extends TypeParameterElement> getTypeParameters(); 60 61 /** 62 * Returns the return type of this executable. 63 * Returns a {@link NoType} with kind {@link TypeKind#VOID VOID} 64 * if this executable is not a method, or is a method that does not 65 * return a value. 66 * 67 * @return the return type of this executable 68 */ 69 TypeMirror getReturnType(); 70 71 /** 72 * Returns the formal parameters of this executable. 73 * They are returned in declaration order. 74 * 75 * @return the formal parameters, 76 * or an empty list if there are none 77 */ 78 List<? extends VariableElement> getParameters(); 79 80 /** 81 * Returns the receiver type of this executable, 82 * or {@link javax.lang.model.type.NoType NoType} with 83 * kind {@link javax.lang.model.type.TypeKind#NONE NONE} 84 * if the executable has no receiver type. 85 * 86 * An executable which is an instance method, or a constructor of an 87 * inner class, has a receiver type derived from the {@linkplain 88 * #getEnclosingElement declaring type}. 89 * 90 * An executable which is a static method, or a constructor of a 91 * non-inner class, or an initializer (static or instance), has no 92 * receiver type. 93 * 94 * @return the receiver type of this executable 95 * @since 1.8 96 */ 97 TypeMirror getReceiverType(); 98 99 /** 100 * Returns {@code true} if this method or constructor accepts a variable 101 * number of arguments and returns {@code false} otherwise. 102 * 103 * @return {@code true} if this method or constructor accepts a variable 104 * number of arguments and {@code false} otherwise 105 */ 106 boolean isVarArgs(); 107 108 /** 109 * Returns {@code true} if this method is a default method and 110 * returns {@code false} otherwise. 111 * 112 * @return {@code true} if this method is a default method and 113 * {@code false} otherwise 114 * @since 1.8 115 */ 116 boolean isDefault(); 117 118 /** 119 * Returns the exceptions and other throwables listed in this 120 * method or constructor's {@code throws} clause in declaration 121 * order. 122 * 123 * @return the exceptions and other throwables listed in the 124 * {@code throws} clause, or an empty list if there are none 125 */ 126 List<? extends TypeMirror> getThrownTypes(); 127 128 /** 129 * Returns the default value if this executable is an annotation 130 * type element. Returns {@code null} if this method is not an 131 * annotation type element, or if it is an annotation type element 132 * with no default value. 133 * 134 * @return the default value, or {@code null} if none 135 */ 136 AnnotationValue getDefaultValue(); 137 138 /** 139 * Returns the simple name of a constructor, method, or 140 * initializer. For a constructor, the name {@code "<init>"} is 141 * returned, for a static initializer, the name {@code "<clinit>"} 142 * is returned, and for an anonymous class or instance 143 * initializer, an empty name is returned. 144 * 145 * @return the simple name of a constructor, method, or 146 * initializer 147 */ 148 @Override 149 Name getSimpleName(); 150 }