removed unused private methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / dom / ITypeBinding.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2008 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.core.dom;
13
14 /**
15  * A type binding represents fully-resolved type. There are a number of
16  * different kinds of type bindings:
17  * <ul>
18  * <li>a class - represents the class declaration;
19  * possibly with type parameters</li>
20  * <li>an interface - represents the class declaration;
21  * possibly with type parameters</li>
22  * <li>an enum - represents the enum declaration (enum types do not have
23  * have type parameters)</li>
24  * <li>an annotation - represents the annotation type declaration
25  * (annotation types do not have have type parameters)</li>
26  * <li>an array type - array types are referenced but not explicitly
27  * declared</li>
28  * <li>a primitive type (including the special return type <code>void</code>)
29  * - primitive types are referenced but not explicitly declared</li>
30  * <li>the null type - this is the special type of <code>null</code></li>
31  * <li>a type variable - represents the declaration of a type variable;
32  * possibly with type bounds</li>
33  * <li>a wildcard type - represents a wild card used as a type argument in
34  * a parameterized type reference</li>
35  * <li>a raw type - represents a legacy non-parameterized reference to
36  * a generic type</li>
37  * <li>a parameterized type - represents an copy of a type declaration
38  * with substitutions for its type parameters</li>
39  * <li>a capture - represents a capture binding</li>
40  * </ul>
41  *
42  * @see ITypeBinding#getDeclaredTypes()
43  * @since 2.0
44  * @noimplement This interface is not intended to be implemented by clients.
45  */
46 public interface ITypeBinding extends IBinding {
47
48
49         /**
50          * Answer an array type binding using the receiver and the given dimension.
51          *
52          * <p>If the receiver is an array binding, then the resulting dimension is the given dimension
53          * plus the dimension of the receiver. Otherwise the resulting dimension is the given
54          * dimension.</p>
55          *
56          * @param dimension the given dimension
57          * @return an array type binding
58          * @throws IllegalArgumentException:<ul>
59          * <li>if the receiver represents the void type</li>
60          * <li>if the resulting dimensions is lower than one or greater than 255</li>
61          * </ul>
62          * @since 3.3
63          */
64         public ITypeBinding createArrayType(int dimension);
65
66         /**
67          * Returns the binary name of this type binding.
68          * The binary name of a class is defined in the Java Language
69          * Specification 3rd edition, section 13.1.
70          * <p>
71          * Note that in some cases, the binary name may be unavailable.
72          * This may happen, for example, for a local type declared in
73          * unreachable code.
74          * </p>
75          *
76          * @return the binary name of this type, or <code>null</code>
77          * if the binary name is unknown
78          * @since 3.0
79          */
80         public String getBinaryName();
81
82         /**
83          * Returns the bound of this wildcard type if it has one.
84          * Returns <code>null</code> if this is not a wildcard type.
85          *
86          * @return the bound of this wildcard type, or <code>null</code> if none
87          * @see #isWildcardType()
88          * @see #isUpperbound()
89          * @since 3.1
90          */
91         public ITypeBinding getBound();
92
93         /**
94          * Returns the binding representing the component type of this array type,
95          * or <code>null</code> if this is not an array type binding. The component
96          * type of an array might be an array type.
97          * <p>This is subject to change before 3.2 release.</p>
98          *
99          * @return the component type binding, or <code>null</code> if this is
100          *   not an array type
101          * @since 3.2
102          */
103         public ITypeBinding getComponentType();
104
105         /**
106          * Returns a list of bindings representing all the fields declared
107          * as members of this class, interface, or enum type.
108          * 
109          * <p>These include public, protected, default (package-private) access,
110          * and private fields declared by the class, but excludes inherited fields.
111          * Synthetic fields may or may not be included. Fields from binary types that
112          * reference unresolvable types may not be included.</p>
113          *
114          * <p>Returns an empty list if the class, interface, or enum declares no fields,
115          * and for other kinds of type bindings that do not directly have members.</p>
116          *
117          * <p>The resulting bindings are in no particular order.</p>
118          *
119          * @return the list of bindings for the field members of this type,
120          *   or the empty list if this type does not have field members
121          */
122         public IVariableBinding[] getDeclaredFields();
123
124         /**
125          * Returns a list of method bindings representing all the methods and
126          * constructors declared for this class, interface, enum, or annotation
127          * type.
128          * <p>These include public, protected, default (package-private) access,
129          * and private methods Synthetic methods and constructors may or may not be
130          * included. Returns an empty list if the class, interface, or enum,
131          * type declares no methods or constructors, if the annotation type declares
132          * no members, or if this type binding represents some other kind of type
133          * binding. Methods from binary types that reference unresolvable types may
134          * not be included.</p>
135          * <p>The resulting bindings are in no particular order.</p>
136          *
137          * @return the list of method bindings for the methods and constructors
138          *   declared by this class, interface, enum type, or annotation type,
139          *   or the empty list if this type does not declare any methods or constructors
140          */
141         public IMethodBinding[] getDeclaredMethods();
142
143         /**
144          * Returns the declared modifiers for this class or interface binding
145          * as specified in the original source declaration of the class or
146          * interface. The result may not correspond to the modifiers in the compiled
147          * binary, since the compiler may change them (in particular, for inner
148          * class emulation). The <code>getModifiers</code> method should be used if
149          * the compiled modifiers are needed. Returns -1 if this type does not
150          * represent a class or interface.
151          *
152          * @return the bit-wise or of <code>Modifier</code> constants
153          * @see #getModifiers()
154          * @see Modifier
155          */
156         public int getDeclaredModifiers();
157
158         /**
159          * Returns a list of type bindings representing all the types declared as
160          * members of this class, interface, or enum type.
161          * These include public, protected, default (package-private) access,
162          * and private classes, interfaces, enum types, and annotation types
163          * declared by the type, but excludes inherited types. Returns an empty
164          * list if the type declares no type members, or if this type
165          * binding represents an array type, a primitive type, a type variable,
166          * a wildcard type, a capture, or the null type.
167          * The resulting bindings are in no particular order.
168          *
169          * @return the list of type bindings for the member types of this type,
170          *   or the empty list if this type does not have member types
171          */
172         public ITypeBinding[] getDeclaredTypes();
173
174         /**
175          * Returns the type binding representing the class, interface, or enum
176          * that declares this binding.
177          * <p>
178          * The declaring class of a member class, interface, enum, annotation
179          * type is the class, interface, or enum type of which it is a member.
180          * The declaring class of a local class or interface (including anonymous
181          * classes) is the innermost class or interface containing the expression
182          * or statement in which this type is declared.
183          * </p>
184          * <p>The declaring class of a type variable is the class in which the type
185          * variable is declared if it is declared on a type. It returns
186          * <code>null</code> otherwise.
187          * </p>
188          * <p>The declaring class of a capture binding is the innermost class or
189          * interface containing the expression or statement in which this capture is
190          * declared.
191          * </p>
192          * <p>Array types, primitive types, the null type, top-level types,
193          * wildcard types, recovered binding have no declaring class.
194          * </p>
195          *
196          * @return the binding of the type that declares this type, or
197          * <code>null</code> if none
198          */
199         public ITypeBinding getDeclaringClass();
200
201         /**
202          * Returns the method binding representing the method that declares this binding
203          * of a local type or type variable.
204          * <p>
205          * The declaring method of a local class or interface (including anonymous
206          * classes) is the innermost method containing the expression or statement in
207          * which this type is declared. Returns <code>null</code> if the type
208          * is declared in an initializer.
209          * </p>
210          * <p>
211          * The declaring method of a type variable is the method in which the type
212          * variable is declared if it is declared on a method. It
213          * returns <code>null</code> otherwise.
214          * </p>
215          * <p>Array types, primitive types, the null type, top-level types,
216          * wildcard types, capture bindings, and recovered binding have no
217          * declaring method.
218          * </p>
219          *
220          * @return the binding of the method that declares this type, or
221          * <code>null</code> if none
222          * @since 3.1
223          */
224         public IMethodBinding getDeclaringMethod();
225
226         /**
227          * Returns the dimensionality of this array type, or <code>0</code> if this
228          * is not an array type binding.
229          *
230          * @return the number of dimension of this array type binding, or
231          *   <code>0</code> if this is not an array type
232          */
233         public int getDimensions();
234
235         /**
236          * Returns the binding representing the element type of this array type,
237          * or <code>null</code> if this is not an array type binding. The element
238          * type of an array is never itself an array type.
239          *
240          * @return the element type binding, or <code>null</code> if this is
241          *   not an array type
242          */
243         public ITypeBinding getElementType();
244
245         /**
246          * Returns the erasure of this type binding.
247          * <ul>
248          * <li>For parameterized types ({@link #isParameterizedType()})
249          * - returns the binding for the corresponding generic type.</li>
250          * <li>For raw types ({@link #isRawType()})
251          * - returns the binding for the corresponding generic type.</li>
252          * <li>For wildcard types ({@link #isWildcardType()})
253          * - returns the binding for the upper bound if it has one and
254          * java.lang.Object in other cases.</li>
255          * <li>For type variables ({@link #isTypeVariable()})
256          * - returns the binding for the erasure of the leftmost bound
257          * if it has bounds and java.lang.Object if it does not.</li>
258          * <li>For captures ({@link #isCapture()})
259          * - returns the binding for the erasure of the leftmost bound
260          * if it has bounds and java.lang.Object if it does not.</li>
261          * <li>For array types ({@link #isArray()}) - returns an array type of
262          * the same dimension ({@link #getDimensions()}) as this type
263          * binding for which the element type is the erasure of the element type
264          * ({@link #getElementType()}) of this type binding.</li>
265          * <li>For all other type bindings - returns the identical binding.</li>
266          * </ul>
267          *
268          * @return the erasure type binding
269          * @since 3.1
270          */
271         public ITypeBinding getErasure();
272
273         /**
274          * Returns a list of type bindings representing the direct superinterfaces
275          * of the class, interface, or enum type represented by this type binding.
276          * <p>
277          * If this type binding represents a class or enum type, the return value
278          * is an array containing type bindings representing all interfaces
279          * directly implemented by this class. The number and order of the interface
280          * objects in the array corresponds to the number and order of the interface
281          * names in the <code>implements</code> clause of the original declaration
282          * of this type.
283          * </p>
284          * <p>
285          * If this type binding represents an interface, the array contains
286          * type bindings representing all interfaces directly extended by this
287          * interface. The number and order of the interface objects in the array
288          * corresponds to the number and order of the interface names in the
289          * <code>extends</code> clause of the original declaration of this interface.
290          * </p>
291          * <p>
292          * If the class or enum implements no interfaces, or the interface extends
293          * no interfaces, or if this type binding represents an array type, a
294          * primitive type, the null type, a type variable, an annotation type,
295          * a wildcard type, or a capture binding, this method returns an array of
296      * length 0.
297          * </p>
298          *
299          * @return the list of type bindings for the interfaces extended by this
300          *   class or enum, or interfaces extended by this interface, or otherwise
301          *   the empty list
302          */
303         public ITypeBinding[] getInterfaces();
304
305         /**
306          * Returns the compiled modifiers for this class, interface, enum,
307          * or annotation type binding.
308          * The result may not correspond to the modifiers as declared in the
309          * original source, since the compiler may change them (in particular,
310          * for inner class emulation). The <code>getDeclaredModifiers</code> method
311          * should be used if the original modifiers are needed.
312          * Returns 0 if this type does not represent a class, an interface, an enum, an annotation
313          * type or a recovered type.
314          *
315          * @return the compiled modifiers for this type binding or 0
316          * if this type does not represent a class, an interface, an enum, an annotation
317          * type or a recovered type.
318          * @see #getDeclaredModifiers()
319          */
320         public int getModifiers();
321
322         /**
323          * Returns the unqualified name of the type represented by this binding
324          * if it has one.
325          * <ul>
326          * <li>For top-level types, member types, and local types,
327          * the name is the simple name of the type.
328          * Example: <code>"String"</code> or <code>"Collection"</code>.
329          * Note that the type parameters of a generic type are not included.</li>
330          * <li>For primitive types, the name is the keyword for the primitive type.
331          * Example: <code>"int"</code>.</li>
332          * <li>For the null type, the name is the string "null".</li>
333          * <li>For anonymous classes, which do not have a name,
334          * this method returns an empty string.</li>
335          * <li>For array types, the name is the unqualified name of the component
336          * type (as computed by this method) followed by "[]".
337          * Example: <code>"String[]"</code>. Note that the component type is never an
338          * an anonymous class.</li>
339          * <li>For type variables, the name is just the simple name of the
340          * type variable (type bounds are not included).
341          * Example: <code>"X"</code>.</li>
342          * <li>For type bindings that correspond to particular instances of a generic
343          * type arising from a parameterized type reference,
344          * the name is the unqualified name of the erasure type (as computed by this method)
345          * followed by the names (again, as computed by this method) of the type arguments
346          * surrounded by "&lt;&gt;" and separated by ",".
347          * Example: <code>"Collection&lt;String&gt;"</code>.
348          * </li>
349          * <li>For type bindings that correspond to particular instances of a generic
350          * type arising from a raw type reference, the name is the unqualified name of
351          * the erasure type (as computed by this method).
352          * Example: <code>"Collection"</code>.</li>
353          * <li>For wildcard types, the name is "?" optionally followed by
354          * a single space followed by the keyword "extends" or "super"
355          * followed a single space followed by the name of the bound (as computed by
356          * this method) when present.
357          * Example: <code>"? extends InputStream"</code>.
358          * </li>
359      * <li>Capture types do not have a name. For these types,
360      * and array types thereof, this method returns an empty string.</li>
361          * </ul>
362          *
363          * @return the unqualified name of the type represented by this binding,
364          * or the empty string if it has none
365          * @see #getQualifiedName()
366          */
367         public String getName();
368
369         /**
370          * Returns the binding for the package in which this type is declared.
371          *
372          * <p>The package of a recovered type reference binding is either
373          * the package of the enclosing type, or, if the type name is the name of a
374          * {@linkplain AST#resolveWellKnownType(String) well-known type},
375          * the package of the matching well-known type.</p>
376          * 
377          * @return the binding for the package in which this class, interface,
378          * enum, or annotation type is declared, or <code>null</code> if this type
379          * binding represents a primitive type, an array type, the null type,
380          * a type variable, a wildcard type, a capture binding.
381          */
382         public IPackageBinding getPackage();
383
384         /**
385          * Returns the fully qualified name of the type represented by this
386          * binding if it has one.
387          * <ul>
388          * <li>For top-level types, the fully qualified name is the simple name of
389          * the type preceded by the package name (or unqualified if in a default package)
390          * and a ".".
391          * Example: <code>"java.lang.String"</code> or <code>"java.util.Collection"</code>.
392          * Note that the type parameters of a generic type are not included.</li>
393          * <li>For members of top-level types, the fully qualified name is the
394          * simple name of the type preceded by the fully qualified name of the
395          * enclosing type (as computed by this method) and a ".".
396          * Example: <code>"java.io.ObjectInputStream.GetField"</code>.
397          * If the binding is for a member type that corresponds to a particular instance
398          * of a generic type arising from a parameterized type reference, the simple
399          * name of the type is followed by the fully qualified names of the type arguments
400          * (as computed by this method) surrounded by "&lt;&gt;" and separated by ",".
401          * Example: <code>"pkg.Outer.Inner&lt;java.lang.String&gt;"</code>.
402          * </li>
403          * <li>For primitive types, the fully qualified name is the keyword for
404          * the primitive type.
405          * Example: <code>"int"</code>.</li>
406          * <li>For the null type, the fully qualified name is the string
407          * "null".</li>
408          * <li>Local types (including anonymous classes) and members of local
409          * types do not have a fully qualified name. For these types, and array
410          * types thereof, this method returns an empty string.</li>
411          * <li>For array types whose component type has a fully qualified name,
412          * the fully qualified name is the fully qualified name of the component
413          * type (as computed by this method) followed by "[]".
414          * Example: <code>"java.lang.String[]"</code>.</li>
415          * <li>For type variables, the fully qualified name is just the name of the
416          * type variable (type bounds are not included).
417          * Example: <code>"X"</code>.</li>
418          * <li>For type bindings that correspond to particular instances of a generic
419          * type arising from a parameterized type reference,
420          * the fully qualified name is the fully qualified name of the erasure
421          * type followed by the fully qualified names of the type arguments surrounded by "&lt;&gt;" and separated by ",".
422          * Example: <code>"java.util.Collection&lt;java.lang.String&gt;"</code>.
423          * </li>
424          * <li>For type bindings that correspond to particular instances of a generic
425          * type arising from a raw type reference,
426          * the fully qualified name is the fully qualified name of the erasure type.
427          * Example: <code>"java.util.Collection"</code>. Note that the
428          * the type parameters are omitted.</li>
429          * <li>For wildcard types, the fully qualified name is "?" optionally followed by
430          * a single space followed by the keyword "extends" or "super"
431          * followed a single space followed by the fully qualified name of the bound
432          * (as computed by this method) when present.
433          * Example: <code>"? extends java.io.InputStream"</code>.
434          * </li>
435     * <li>Capture types do not have a fully qualified name. For these types,
436     * and array types thereof, this method returns an empty string.</li>
437          * </ul>
438          *
439          * @return the fully qualified name of the type represented by this
440          *    binding, or the empty string if it has none
441          * @see #getName()
442          * @since 2.1
443          */
444         public String getQualifiedName();
445
446         /**
447          * Returns the type binding for the superclass of the type represented
448          * by this class binding.
449          * <p>
450          * If this type binding represents any class other than the class
451          * <code>java.lang.Object</code>, then the type binding for the direct
452          * superclass of this class is returned. If this type binding represents
453          * the class <code>java.lang.Object</code>, then <code>null</code> is
454          * returned.
455          * <p>
456          * Loops that ascend the class hierarchy need a suitable termination test.
457          * Rather than test the superclass for <code>null</code>, it is more
458          * transparent to check whether the class is <code>Object</code>, by
459          * comparing whether the class binding is identical to
460          * <code>ast.resolveWellKnownType("java.lang.Object")</code>.
461          * </p>
462          * <p>
463          * If this type binding represents an interface, an array type, a
464          * primitive type, the null type, a type variable, an enum type,
465          * an annotation type, a wildcard type, or a capture binding then
466          * <code>null</code> is returned.
467          * </p>
468          *
469          * @return the superclass of the class represented by this type binding,
470          *    or <code>null</code> if none
471          * @see AST#resolveWellKnownType(String)
472          */
473         public ITypeBinding getSuperclass();
474
475         /**
476          * Returns the type arguments of this generic type instance, or the
477          * empty list for other type bindings.
478          * <p>
479          * Note that type arguments only occur on a type binding that represents
480          * an instance of a generic type corresponding to a parameterized type
481          * reference (e.g., <code>Collection&lt;String&gt;</code>).
482          * Do not confuse these with type parameters which only occur on the
483          * type binding corresponding directly to the declaration of the
484          * generic class or interface (e.g., <code>Collection&lt;T&gt;</code>).
485          * </p>
486          *
487          * @return the list of type bindings for the type arguments used to
488          * instantiate the corresponding generic type, or otherwise the empty list
489          * @see #getTypeDeclaration()
490          * @see #isGenericType()
491          * @see #isParameterizedType()
492          * @see #isRawType()
493          * @since 3.1
494          */
495         public ITypeBinding[] getTypeArguments();
496
497         /**
498          * Returns the declared type bounds of this type variable or capture. If the
499          * variable or the capture had no explicit bound, then it returns an empty list.
500      * <p>
501      * Note that per construction, it can only contain one class or array type,
502      * at most, and then it is located in first position.
503      * </p>
504      * <p>
505      * Also note that array type bound may only occur in the case of a capture
506      * binding, e.g. <code>capture-of ? extends Object[]</code>
507      * </p>
508          *
509          * @return the list of type bindings for this type variable or capture,
510      * or otherwise the empty list
511          * @see #isCapture()
512          * @see #isTypeVariable()
513          * @since 3.1
514          */
515         public ITypeBinding[] getTypeBounds();
516
517         /**
518          * Returns the binding for the type declaration corresponding to this type
519          * binding.
520          * <p>For parameterized types ({@link #isParameterizedType()})
521          * and most raw types ({@link #isRawType()}), this method returns the binding
522          * for the corresponding generic type.</p>
523          * <p>For raw member types ({@link #isRawType()}, {@link #isMember()})
524          * of a raw declaring class, the type declaration is a generic or a non-generic
525          * type.</p>
526          * <p>A different non-generic binding will be returned when one of the declaring
527          * types/methods was parameterized.</p>
528          * <p>For other type bindings, this returns the same binding.</p>
529          *
530          * @return the type binding
531          * @since 3.1
532          */
533         public ITypeBinding getTypeDeclaration();
534
535         /**
536          * Returns the type parameters of this class or interface type binding.
537          * <p>
538          * Note that type parameters only occur on the binding of the
539          * declaring generic class or interface; e.g., <code>Collection&lt;T&gt;</code>.
540          * Type bindings corresponding to a raw or parameterized reference to a generic
541          * type do not carry type parameters (they instead have non-empty type arguments
542          * and non-trivial erasure).
543          * </p>
544          *
545          * @return the list of binding for the type variables for the type
546          * parameters of this type, or otherwise the empty list
547          * @see #isTypeVariable()
548          * @since 3.1
549          */
550         // TODO (jeem) - clarify whether binding for a generic type instance carries a copy of the generic type's type parameters as well as type arguments
551         public ITypeBinding[] getTypeParameters();
552
553         /**
554          * Returns the corresponding wildcard binding of this capture binding.
555      * Returns <code>null</code> if this type bindings does not represent
556      * a capture binding.
557          *
558          * @return the corresponding wildcard binding for a capture
559          * binding, <code>null</code> otherwise
560          * @since 3.1
561          */
562         public ITypeBinding getWildcard();
563
564         /**
565          * Returns whether this type binding represents an annotation type.
566          * <p>
567          * Note that an annotation type is always an interface.
568          * </p>
569          *
570          * @return <code>true</code> if this object represents an annotation type,
571          *    and <code>false</code> otherwise
572          * @since 3.1
573          */
574         public boolean isAnnotation();
575
576         /**
577          * Returns whether this type binding represents an anonymous class.
578          * <p>
579          * An anonymous class is a subspecies of local class, and therefore mutually
580          * exclusive with member types. Note that anonymous classes have no name
581          * (<code>getName</code> returns the empty string).
582          * </p>
583          *
584          * @return <code>true</code> if this type binding is for an anonymous class,
585          *   and <code>false</code> otherwise
586          */
587         public boolean isAnonymous();
588
589         /**
590          * Returns whether this type binding represents an array type.
591          *
592          * @return <code>true</code> if this type binding is for an array type,
593          *   and <code>false</code> otherwise
594          * @see #getElementType()
595          * @see #getDimensions()
596          */
597         public boolean isArray();
598
599         /**
600          * Returns whether an expression of this type can be assigned to a variable
601          * of the given type, as specified in section 5.2 of <em>The Java Language
602          * Specification, Third Edition</em> (JLS3).
603          *
604          * <p>If the receiver or the argument is a recovered type, the answer is always false,
605          * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
606          *
607          * @param variableType the type of a variable to check compatibility against
608          * @return <code>true</code> if an expression of this type can be assigned to a
609          *   variable of the given type, and <code>false</code> otherwise
610          * @since 3.1
611          */
612         public boolean isAssignmentCompatible(ITypeBinding variableType);
613
614         /**
615          * Returns whether this type binding represents a capture binding.
616          * <p>
617          * Capture bindings result from capture conversion as specified
618          * in section 5.1.10 of <em>The Java Language Specification,
619          * Third Edition</em> (JLS3).
620          * </p>
621          * <p>
622          * A capture binding may have upper bounds and a lower bound.
623          * Upper bounds may be accessed using {@link #getTypeBounds()},
624          * the lower bound must be accessed indirectly through the associated
625          * wildcard {@link #getWildcard()} when it is a lower bound wildcard.
626          * </p>
627          * <p>
628          * Note that capture bindings are distinct from type variables
629      * (even though they are often depicted as synthetic type
630      * variables); as such, {@link #isTypeVariable()} answers
631      * <code>false</code> for capture bindings, and
632      * {@link #isCapture()} answers <code>false</code> for type variables.
633          * </p>
634      *
635          * @return <code>true</code> if this type binding is a capture,
636          *   and <code>false</code> otherwise
637          * @see #getTypeBounds()
638          * @see #getWildcard()
639          * @since 3.1
640          */
641         public boolean isCapture();
642
643         /**
644          * Returns whether this type is cast compatible with the given type,
645          * as specified in section 5.5 of <em>The Java Language
646          * Specification, Third Edition</em> (JLS3).
647          * <p>
648          * NOTE: The cast compatibility check performs backwards.
649          * When testing whether type B can be cast to type A, one would use:
650          * <code>A.isCastCompatible(B)</code>
651          * </p>
652          *
653          * <p>If the receiver or the argument is a recovered type, the answer is always false,
654          * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
655          *
656          * @param type the type to check compatibility against
657          * @return <code>true</code> if this type is cast compatible with the
658          * given type, and <code>false</code> otherwise
659          * @since 3.1
660          */
661         public boolean isCastCompatible(ITypeBinding type);
662
663         /**
664          * Returns whether this type binding represents a class type or a recovered binding.
665          *
666          * @return <code>true</code> if this object represents a class or a recovered binding,
667          *    and <code>false</code> otherwise
668          */
669         public boolean isClass();
670
671         /**
672          * Returns whether this type binding represents an enum type.
673          *
674          * @return <code>true</code> if this object represents an enum type,
675          *    and <code>false</code> otherwise
676          * @since 3.1
677          */
678         public boolean isEnum();
679
680         /**
681          * Returns whether this type binding originated in source code.
682          * Returns <code>false</code> for all primitive types, the null type,
683          * array types, and for all classes, interfaces, enums, annotation
684          * types, type variables, parameterized type references,
685          * raw type references, wildcard types, and capture bindings
686      * whose information came from a pre-compiled binary class file.
687          *
688          * @return <code>true</code> if the type is in source code,
689          *    and <code>false</code> otherwise
690          */
691         public boolean isFromSource();
692
693         /**
694          * Returns whether this type binding represents a declaration of
695          * a generic class or interface.
696          * <p>
697          * Note that type parameters only occur on the binding of the
698          * declaring generic class or interface; e.g., <code>Collection&lt;T&gt;</code>.
699          * Type bindings corresponding to a raw or parameterized reference to a generic
700          * type do not carry type parameters (they instead have non-empty type arguments
701          * and non-trivial erasure).
702          * This method is fully equivalent to <code>getTypeParameters().length &gt; 0)</code>.
703          * </p>
704          * <p>
705          * Note that {@link #isGenericType()},
706          * {@link #isParameterizedType()},
707          * and {@link #isRawType()} are mutually exclusive.
708          * </p>
709          *
710          * @return <code>true</code> if this type binding represents a
711          * declaration of a generic class or interface, and <code>false</code> otherwise
712          * @see #getTypeParameters()
713          * @since 3.1
714          */
715         public boolean isGenericType();
716
717         /**
718          * Returns whether this type binding represents an interface type.
719          * <p>
720          * Note that an interface can also be an annotation type.
721          * </p>
722          *
723          * @return <code>true</code> if this object represents an interface,
724          *    and <code>false</code> otherwise
725          */
726         public boolean isInterface();
727
728         /**
729          * Returns whether this type binding represents a local class.
730          * <p>
731          * A local class is any nested class or enum type not declared as a member
732          * of another class or interface. A local class is a subspecies of nested
733          * type, and mutually exclusive with member types. Note that anonymous
734          * classes are a subspecies of local classes.
735          * </p>
736          * <p>
737          * Also note that interfaces and annotation types cannot be local.
738          * </p>
739          *
740          * @return <code>true</code> if this type binding is for a local class or
741          * enum type, and <code>false</code> otherwise
742          */
743         public boolean isLocal();
744
745         /**
746          * Returns whether this type binding represents a member class or
747          * interface.
748          * <p>
749          * A member type is any type declared as a member of
750          * another type. A member type is a subspecies of nested
751          * type, and mutually exclusive with local types.
752          * </p>
753          *
754          * @return <code>true</code> if this type binding is for a member class,
755          *   interface, enum, or annotation type, and <code>false</code> otherwise
756          */
757         public boolean isMember();
758
759         /**
760          * Returns whether this type binding represents a nested class, interface,
761          * enum, or annotation type.
762          * <p>
763          * A nested type is any type whose declaration occurs within
764          * the body of another. The set of nested types is disjoint from the set of
765          * top-level types. Nested types further subdivide into member types, local
766          * types, and anonymous types.
767          * </p>
768          *
769          * @return <code>true</code> if this type binding is for a nested class,
770          *   interface, enum, or annotation type, and <code>false</code> otherwise
771          */
772         public boolean isNested();
773
774         /**
775          * Returns whether this type binding represents the null type.
776          * <p>
777          * The null type is the type of a <code>NullLiteral</code> node.
778          * </p>
779          *
780          * @return <code>true</code> if this type binding is for the null type,
781          *   and <code>false</code> otherwise
782          */
783         public boolean isNullType();
784
785         /**
786          * Returns whether this type binding represents an instance of
787          * a generic type corresponding to a parameterized type reference.
788          * <p>
789          * For example, an AST type like
790          * <code>Collection&lt;String&gt;</code> typically resolves to a
791          * type binding whose type argument is the type binding for the
792          * class <code>java.lang.String</code> and whose erasure is the type
793          * binding for the generic type <code>java.util.Collection</code>.
794          * </p>
795          * <p>
796          * Note that {@link #isGenericType()},
797          * {@link #isParameterizedType()},
798          * and {@link #isRawType()} are mutually exclusive.
799          * </p>
800          *
801          * @return <code>true</code> if this type binding represents a
802          * an instance of a generic type corresponding to a parameterized
803          * type reference, and <code>false</code> otherwise
804          * @see #getTypeArguments()
805          * @see #getTypeDeclaration()
806          * @since 3.1
807          */
808         public boolean isParameterizedType();
809
810         /**
811          * Returns whether this type binding represents a primitive type.
812          * <p>
813          * There are nine predefined type bindings to represent the eight primitive
814          * types and <code>void</code>. These have the same names as the primitive
815          * types that they represent, namely boolean, byte, char, short, int,
816          * long, float, and double, and void.
817          * </p>
818          *
819          * @return <code>true</code> if this type binding is for a primitive type,
820          *   and <code>false</code> otherwise
821          */
822         public boolean isPrimitive();
823
824         /**
825          * Returns whether this type binding represents an instance of
826          * a generic type corresponding to a raw type reference.
827          * <p>
828          * For example, an AST type like
829          * <code>Collection</code> typically resolves to a
830          * type binding whose type argument is the type binding for
831          * the class <code>java.lang.Object</code> (the
832          * default bound for the single type parameter of
833          * <code>java.util.Collection</code>) and whose erasure is the
834          * type binding for the generic type
835          * <code>java.util.Collection</code>.
836          * </p>
837          * <p>
838          * Note that {@link #isGenericType()},
839          * {@link #isParameterizedType()},
840          * and {@link #isRawType()} are mutually exclusive.
841          * </p>
842          *
843          * @return <code>true</code> if this type binding represents a
844          * an instance of a generic type corresponding to a raw
845          * type reference, and <code>false</code> otherwise
846          * @see #getTypeDeclaration()
847          * @see #getTypeArguments()
848          * @since 3.1
849          */
850         public boolean isRawType();
851
852         /**
853          * Returns whether this type is subtype compatible with the given type,
854          * as specified in section 4.10 of <em>The Java Language
855          * Specification, Third Edition</em> (JLS3).
856          *
857          * <p>If the receiver or the argument is a recovered type, the answer is always false,
858          * unless the two types are identical or the argument is <code>java.lang.Object</code>.</p>
859          *
860          * @param type the type to check compatibility against
861          * @return <code>true</code> if this type is subtype compatible with the
862          * given type, and <code>false</code> otherwise
863          * @since 3.1
864          */
865         public boolean isSubTypeCompatible(ITypeBinding type);
866
867         /**
868          * Returns whether this type binding represents a top-level class,
869          * interface, enum, or annotation type.
870          * <p>
871          * A top-level type is any type whose declaration does not occur within the
872          * body of another type declaration. The set of top level types is disjoint
873          * from the set of nested types.
874          * </p>
875          *
876          * @return <code>true</code> if this type binding is for a top-level class,
877          *   interface, enum, or annotation type, and <code>false</code> otherwise
878          */
879         public boolean isTopLevel();
880
881         /**
882          * Returns whether this type binding represents a type variable.
883          * Type variables bindings carry the type variable's bounds.
884      * <p>
885      * Note that type variables are distinct from capture bindings
886      * (even though capture bindings are often depicted as synthetic
887      * type variables); as such, {@link #isTypeVariable()} answers
888      * <code>false</code> for capture bindings, and
889      * {@link #isCapture()} answers <code>false</code> for type variables.
890      * </p>
891          *
892          * @return <code>true</code> if this type binding is for a type variable,
893          *   and <code>false</code> otherwise
894          * @see #getName()
895          * @see #getTypeBounds()
896          * @since 3.1
897          */
898         public boolean isTypeVariable();
899
900         /**
901          * Returns whether this wildcard type is an upper bound
902          * ("extends") as opposed to a lower bound ("super").
903          * Note that this property is only relevant for wildcards
904          * that have a bound.
905          *
906          * @return <code>true</code> if this wildcard type has a bound that is
907          * an upper bound, and <code>false</code> in all other cases
908          * @see #isWildcardType()
909          * @see #getBound()
910          * @since 3.1
911          */
912         public boolean isUpperbound();
913
914         /**
915          * Returns whether this type binding represents a wildcard type. A wildcard
916          * type occus only as an argument to a parameterized type reference.
917          * <p>
918          * For example, a AST type like
919          * <code>Collection&lt;? extends Object&gt;</code> typically resolves to a
920          * parameterized type binding whose type argument is a wildcard type
921          * with upper type bound <code>java.util.Object</code>.
922          * </p>
923          *
924          * @return <code>true</code> if this object represents a wildcard type,
925          *    and <code>false</code> otherwise
926          * @since 3.1
927          * @see #getBound()
928          * @see #isUpperbound()
929          */
930         public boolean isWildcardType();
931 }