View Javadoc
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.type;
27  
28  
29  import java.util.List;
30  
31  import javax.lang.model.element.ExecutableElement;
32  
33  /**
34   * Represents the type of an executable.  An <i>executable</i>
35   * is a method, constructor, or initializer.
36   *
37   * <p> The executable is
38   * represented as when viewed as a method (or constructor or
39   * initializer) of some reference type.
40   * If that reference type is parameterized, then its actual
41   * type arguments are substituted into any types returned by the methods of
42   * this interface.
43   *
44   * @author Joseph D. Darcy
45   * @author Scott Seligman
46   * @author Peter von der Ah&eacute;
47   * @see ExecutableElement
48   * @since 1.6
49   */
50  public interface ExecutableType extends TypeMirror {
51  
52      /**
53       * Returns the type variables declared by the formal type parameters
54       * of this executable.
55       *
56       * @return the type variables declared by the formal type parameters,
57       *          or an empty list if there are none
58       */
59      List<? extends TypeVariable> getTypeVariables();
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 types of this executable's formal parameters.
73       *
74       * @return the types of this executable's formal parameters,
75       *          or an empty list if there are none
76       */
77      List<? extends TypeMirror> getParameterTypes();
78  
79      /**
80       * Returns the receiver type of this executable,
81       * or {@link javax.lang.model.type.NoType NoType} with
82       * kind {@link javax.lang.model.type.TypeKind#NONE NONE}
83       * if the executable has no receiver type.
84       *
85       * An executable which is an instance method, or a constructor of an
86       * inner class, has a receiver type derived from the {@linkplain
87       * ExecutableElement#getEnclosingElement declaring type}.
88       *
89       * An executable which is a static method, or a constructor of a
90       * non-inner class, or an initializer (static or instance), has no
91       * receiver type.
92       *
93       * @return the receiver type of this executable
94       * @since 1.8
95       */
96      TypeMirror getReceiverType();
97  
98      /**
99       * Returns the exceptions and other throwables listed in this
100      * executable's {@code throws} clause.
101      *
102      * @return the exceptions and other throwables listed in this
103      *          executable's {@code throws} clause,
104      *          or an empty list if there are none.
105      */
106     List<? extends TypeMirror> getThrownTypes();
107 }