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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.core.dom;
15 * A type binding represents fully-resolved type. There are a number of
16 * different kinds of type bindings:
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
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
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>
42 * @see ITypeBinding#getDeclaredTypes()
44 * @noimplement This interface is not intended to be implemented by clients.
46 public interface ITypeBinding extends IBinding {
50 * Answer an array type binding using the receiver and the given dimension.
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
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>
64 public ITypeBinding createArrayType(int dimension);
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.
71 * Note that in some cases, the binary name may be unavailable.
72 * This may happen, for example, for a local type declared in
76 * @return the binary name of this type, or <code>null</code>
77 * if the binary name is unknown
80 public String getBinaryName();
83 * Returns the bound of this wildcard type if it has one.
84 * Returns <code>null</code> if this is not a wildcard type.
86 * @return the bound of this wildcard type, or <code>null</code> if none
87 * @see #isWildcardType()
88 * @see #isUpperbound()
91 public ITypeBinding getBound();
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>
99 * @return the component type binding, or <code>null</code> if this is
103 public ITypeBinding getComponentType();
106 * Returns a list of bindings representing all the fields declared
107 * as members of this class, interface, or enum type.
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>
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>
117 * <p>The resulting bindings are in no particular order.</p>
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
122 public IVariableBinding[] getDeclaredFields();
125 * Returns a list of method bindings representing all the methods and
126 * constructors declared for this class, interface, enum, or annotation
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>
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
141 public IMethodBinding[] getDeclaredMethods();
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.
152 * @return the bit-wise or of <code>Modifier</code> constants
153 * @see #getModifiers()
156 public int getDeclaredModifiers();
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.
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
172 public ITypeBinding[] getDeclaredTypes();
175 * Returns the type binding representing the class, interface, or enum
176 * that declares this binding.
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.
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.
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
192 * <p>Array types, primitive types, the null type, top-level types,
193 * wildcard types, recovered binding have no declaring class.
196 * @return the binding of the type that declares this type, or
197 * <code>null</code> if none
199 public ITypeBinding getDeclaringClass();
202 * Returns the method binding representing the method that declares this binding
203 * of a local type or type variable.
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.
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.
215 * <p>Array types, primitive types, the null type, top-level types,
216 * wildcard types, capture bindings, and recovered binding have no
220 * @return the binding of the method that declares this type, or
221 * <code>null</code> if none
224 public IMethodBinding getDeclaringMethod();
227 * Returns the dimensionality of this array type, or <code>0</code> if this
228 * is not an array type binding.
230 * @return the number of dimension of this array type binding, or
231 * <code>0</code> if this is not an array type
233 public int getDimensions();
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.
240 * @return the element type binding, or <code>null</code> if this is
243 public ITypeBinding getElementType();
246 * Returns the erasure of this type binding.
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>
268 * @return the erasure type binding
271 public ITypeBinding getErasure();
274 * Returns a list of type bindings representing the direct superinterfaces
275 * of the class, interface, or enum type represented by this type binding.
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
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.
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
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
303 public ITypeBinding[] getInterfaces();
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.
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()
320 public int getModifiers();
323 * Returns the unqualified name of the type represented by this binding
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 "<>" and separated by ",".
347 * Example: <code>"Collection<String>"</code>.
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>.
359 * <li>Capture types do not have a name. For these types,
360 * and array types thereof, this method returns an empty string.</li>
363 * @return the unqualified name of the type represented by this binding,
364 * or the empty string if it has none
365 * @see #getQualifiedName()
367 public String getName();
370 * Returns the binding for the package in which this type is declared.
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>
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.
382 public IPackageBinding getPackage();
385 * Returns the fully qualified name of the type represented by this
386 * binding if it has one.
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)
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 "<>" and separated by ",".
401 * Example: <code>"pkg.Outer.Inner<java.lang.String>"</code>.
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
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 "<>" and separated by ",".
422 * Example: <code>"java.util.Collection<java.lang.String>"</code>.
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>.
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>
439 * @return the fully qualified name of the type represented by this
440 * binding, or the empty string if it has none
444 public String getQualifiedName();
447 * Returns the type binding for the superclass of the type represented
448 * by this class binding.
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
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>.
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.
469 * @return the superclass of the class represented by this type binding,
470 * or <code>null</code> if none
471 * @see AST#resolveWellKnownType(String)
473 public ITypeBinding getSuperclass();
476 * Returns the type arguments of this generic type instance, or the
477 * empty list for other type bindings.
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<String></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<T></code>).
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()
495 public ITypeBinding[] getTypeArguments();
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.
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.
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>
509 * @return the list of type bindings for this type variable or capture,
510 * or otherwise the empty list
512 * @see #isTypeVariable()
515 public ITypeBinding[] getTypeBounds();
518 * Returns the binding for the type declaration corresponding to this type
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
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>
530 * @return the type binding
533 public ITypeBinding getTypeDeclaration();
536 * Returns the type parameters of this class or interface type binding.
538 * Note that type parameters only occur on the binding of the
539 * declaring generic class or interface; e.g., <code>Collection<T></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).
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()
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();
554 * Returns the corresponding wildcard binding of this capture binding.
555 * Returns <code>null</code> if this type bindings does not represent
558 * @return the corresponding wildcard binding for a capture
559 * binding, <code>null</code> otherwise
562 public ITypeBinding getWildcard();
565 * Returns whether this type binding represents an annotation type.
567 * Note that an annotation type is always an interface.
570 * @return <code>true</code> if this object represents an annotation type,
571 * and <code>false</code> otherwise
574 public boolean isAnnotation();
577 * Returns whether this type binding represents an anonymous class.
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).
584 * @return <code>true</code> if this type binding is for an anonymous class,
585 * and <code>false</code> otherwise
587 public boolean isAnonymous();
590 * Returns whether this type binding represents an array type.
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()
597 public boolean isArray();
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).
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>
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
612 public boolean isAssignmentCompatible(ITypeBinding variableType);
615 * Returns whether this type binding represents a capture binding.
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).
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.
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.
635 * @return <code>true</code> if this type binding is a capture,
636 * and <code>false</code> otherwise
637 * @see #getTypeBounds()
638 * @see #getWildcard()
641 public boolean isCapture();
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).
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>
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>
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
661 public boolean isCastCompatible(ITypeBinding type);
664 * Returns whether this type binding represents a class type or a recovered binding.
666 * @return <code>true</code> if this object represents a class or a recovered binding,
667 * and <code>false</code> otherwise
669 public boolean isClass();
672 * Returns whether this type binding represents an enum type.
674 * @return <code>true</code> if this object represents an enum type,
675 * and <code>false</code> otherwise
678 public boolean isEnum();
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.
688 * @return <code>true</code> if the type is in source code,
689 * and <code>false</code> otherwise
691 public boolean isFromSource();
694 * Returns whether this type binding represents a declaration of
695 * a generic class or interface.
697 * Note that type parameters only occur on the binding of the
698 * declaring generic class or interface; e.g., <code>Collection<T></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 > 0)</code>.
705 * Note that {@link #isGenericType()},
706 * {@link #isParameterizedType()},
707 * and {@link #isRawType()} are mutually exclusive.
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()
715 public boolean isGenericType();
718 * Returns whether this type binding represents an interface type.
720 * Note that an interface can also be an annotation type.
723 * @return <code>true</code> if this object represents an interface,
724 * and <code>false</code> otherwise
726 public boolean isInterface();
729 * Returns whether this type binding represents a local class.
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.
737 * Also note that interfaces and annotation types cannot be local.
740 * @return <code>true</code> if this type binding is for a local class or
741 * enum type, and <code>false</code> otherwise
743 public boolean isLocal();
746 * Returns whether this type binding represents a member class or
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.
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
757 public boolean isMember();
760 * Returns whether this type binding represents a nested class, interface,
761 * enum, or annotation type.
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.
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
772 public boolean isNested();
775 * Returns whether this type binding represents the null type.
777 * The null type is the type of a <code>NullLiteral</code> node.
780 * @return <code>true</code> if this type binding is for the null type,
781 * and <code>false</code> otherwise
783 public boolean isNullType();
786 * Returns whether this type binding represents an instance of
787 * a generic type corresponding to a parameterized type reference.
789 * For example, an AST type like
790 * <code>Collection<String></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>.
796 * Note that {@link #isGenericType()},
797 * {@link #isParameterizedType()},
798 * and {@link #isRawType()} are mutually exclusive.
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()
808 public boolean isParameterizedType();
811 * Returns whether this type binding represents a primitive type.
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.
819 * @return <code>true</code> if this type binding is for a primitive type,
820 * and <code>false</code> otherwise
822 public boolean isPrimitive();
825 * Returns whether this type binding represents an instance of
826 * a generic type corresponding to a raw type reference.
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>.
838 * Note that {@link #isGenericType()},
839 * {@link #isParameterizedType()},
840 * and {@link #isRawType()} are mutually exclusive.
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()
850 public boolean isRawType();
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).
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>
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
865 public boolean isSubTypeCompatible(ITypeBinding type);
868 * Returns whether this type binding represents a top-level class,
869 * interface, enum, or annotation type.
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.
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
879 public boolean isTopLevel();
882 * Returns whether this type binding represents a type variable.
883 * Type variables bindings carry the type variable's bounds.
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.
892 * @return <code>true</code> if this type binding is for a type variable,
893 * and <code>false</code> otherwise
895 * @see #getTypeBounds()
898 public boolean isTypeVariable();
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
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()
912 public boolean isUpperbound();
915 * Returns whether this type binding represents a wildcard type. A wildcard
916 * type occus only as an argument to a parameterized type reference.
918 * For example, a AST type like
919 * <code>Collection<? extends Object></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>.
924 * @return <code>true</code> if this object represents a wildcard type,
925 * and <code>false</code> otherwise
928 * @see #isUpperbound()
930 public boolean isWildcardType();