< prev index next >

src/java.compiler/share/classes/javax/lang/model/element/ExecutableElement.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2019, 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


  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&eacute;
  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 executable type defined by this executable element
  48      *
  49      * @see ExecutableType
  50      */
  51     @Override
  52     TypeMirror asType();
  53 
  54     /**
  55      * Returns the formal type parameters of this executable
  56      * in declaration order.
  57      *
  58      * @return the formal type parameters, or an empty list
  59      * if there are none
  60      */
  61     List<? extends TypeParameterElement> getTypeParameters();
  62 
  63     /**
  64      * Returns the return type of this executable.
  65      * Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
  66      * if this executable is not a method, or is a method that does not
  67      * return a value.
  68      *
  69      * @return the return type of this executable
  70      */
  71     TypeMirror getReturnType();
  72 
  73     /**
  74      * Returns the formal parameters of this executable.


  78      * or an empty list if there are none
  79      */
  80     List<? extends VariableElement> getParameters();
  81 
  82     /**
  83      * Returns the receiver type of this executable,
  84      * or {@link javax.lang.model.type.NoType NoType} with
  85      * kind {@link javax.lang.model.type.TypeKind#NONE NONE}
  86      * if the executable has no receiver type.
  87      *
  88      * An executable which is an instance method, or a constructor of an
  89      * inner class, has a receiver type derived from the {@linkplain
  90      * #getEnclosingElement declaring type}.
  91      *
  92      * An executable which is a static method, or a constructor of a
  93      * non-inner class, or an initializer (static or instance), has no
  94      * receiver type.
  95      *
  96      * @return the receiver type of this executable
  97      * @since 1.8
  98      *
  99      * @jls 8.4 Method Declarations
 100      * @jls 8.4.1 Formal Parameters
 101      * @jls 8.8 Constructor Declarations
 102      */
 103     TypeMirror getReceiverType();
 104 
 105     /**
 106      * Returns {@code true} if this method or constructor accepts a variable
 107      * number of arguments and returns {@code false} otherwise.
 108      *
 109      * @return {@code true} if this method or constructor accepts a variable
 110      * number of arguments and {@code false} otherwise
 111      */
 112     boolean isVarArgs();
 113 
 114     /**
 115      * Returns {@code true} if this method is a default method and
 116      * returns {@code false} otherwise.
 117      *
 118      * @return {@code true} if this method is a default method and
 119      * {@code false} otherwise
 120      * @since 1.8
 121      */


   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


  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&eacute;
  39  * @see ExecutableType
  40  * @since 1.6
  41  */
  42 public interface ExecutableElement extends Element, Parameterizable {
  43     /**











  44      * Returns the formal type parameters of this executable
  45      * in declaration order.
  46      *
  47      * @return the formal type parameters, or an empty list
  48      * if there are none
  49      */
  50     List<? extends TypeParameterElement> getTypeParameters();
  51 
  52     /**
  53      * Returns the return type of this executable.
  54      * Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
  55      * if this executable is not a method, or is a method that does not
  56      * return a value.
  57      *
  58      * @return the return type of this executable
  59      */
  60     TypeMirror getReturnType();
  61 
  62     /**
  63      * Returns the formal parameters of this executable.


  67      * or an empty list if there are none
  68      */
  69     List<? extends VariableElement> getParameters();
  70 
  71     /**
  72      * Returns the receiver type of this executable,
  73      * or {@link javax.lang.model.type.NoType NoType} with
  74      * kind {@link javax.lang.model.type.TypeKind#NONE NONE}
  75      * if the executable has no receiver type.
  76      *
  77      * An executable which is an instance method, or a constructor of an
  78      * inner class, has a receiver type derived from the {@linkplain
  79      * #getEnclosingElement declaring type}.
  80      *
  81      * An executable which is a static method, or a constructor of a
  82      * non-inner class, or an initializer (static or instance), has no
  83      * receiver type.
  84      *
  85      * @return the receiver type of this executable
  86      * @since 1.8




  87      */
  88     TypeMirror getReceiverType();
  89 
  90     /**
  91      * Returns {@code true} if this method or constructor accepts a variable
  92      * number of arguments and returns {@code false} otherwise.
  93      *
  94      * @return {@code true} if this method or constructor accepts a variable
  95      * number of arguments and {@code false} otherwise
  96      */
  97     boolean isVarArgs();
  98 
  99     /**
 100      * Returns {@code true} if this method is a default method and
 101      * returns {@code false} otherwise.
 102      *
 103      * @return {@code true} if this method is a default method and
 104      * {@code false} otherwise
 105      * @since 1.8
 106      */


< prev index next >