+/**
+ * Returns true if the type is parameterized, e.g. List<String>
+ */
+public boolean isParameterizedType() {
+ return false;
+}
+
+public boolean isPartOfRawType() {
+ TypeBinding current = this;
+ do {
+ if (current.isRawType())
+ return true;
+ } while ((current = current.enclosingType()) != null);
+ return false;
+}
+
+/**
+ * Returns true if the two types are statically known to be different at compile-time,
+ * e.g. a type variable is not probably known to be distinct from another type
+ */
+public boolean isProvablyDistinctFrom(TypeBinding otherType, int depth) {
+ if (this == otherType) return false;
+ if (depth > 1) return true;
+ switch (otherType.kind()) {
+ case Binding.TYPE_PARAMETER :
+ case Binding.WILDCARD_TYPE :
+ return false;
+ }
+ switch(kind()) {
+
+ case Binding.TYPE_PARAMETER :
+ case Binding.WILDCARD_TYPE :
+ return false;
+
+ case Binding.PARAMETERIZED_TYPE :
+ ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) this;
+ if (parameterizedType.type.isProvablyDistinctFrom(otherType.erasure(), depth)) return true;
+ switch (otherType.kind()) {
+ case Binding.GENERIC_TYPE :
+ case Binding.RAW_TYPE :
+ return false;
+ case Binding.PARAMETERIZED_TYPE :
+ TypeBinding[] arguments = parameterizedType.arguments;
+ if (arguments == null) return false;
+ ParameterizedTypeBinding otherParameterizedType = (ParameterizedTypeBinding) otherType;
+ TypeBinding[] otherArguments = otherParameterizedType.arguments;
+ if (otherArguments == null) return false;
+ for (int i = 0, length = arguments.length; i < length; i++) {
+ if (arguments[i].isProvablyDistinctFrom(otherArguments[i], depth+1)) return true;
+ }
+ return false;
+
+ }
+ break;
+
+ case Binding.RAW_TYPE :
+ return this.erasure().isProvablyDistinctFrom(otherType.erasure(), 0);
+
+ case Binding.GENERIC_TYPE :
+ return this != otherType.erasure();
+ }
+ return this != otherType;
+}
+
+public boolean isRawType() {
+ return false;
+}
+
+/**
+ * JLS(3) 4.7
+ */
+public boolean isReifiable() {
+
+ TypeBinding leafType = leafComponentType();
+ if (!(leafType instanceof ReferenceBinding))
+ return true;
+ ReferenceBinding current = (ReferenceBinding) leafType;
+ do {
+ switch(current.kind()) {
+
+ case Binding.TYPE_PARAMETER :
+ case Binding.WILDCARD_TYPE :
+ case Binding.GENERIC_TYPE :
+ return false;
+
+ case Binding.PARAMETERIZED_TYPE :
+ if (isBoundParameterizedType())
+ return false;
+ break;
+
+ case Binding.RAW_TYPE :
+ return true;
+ }
+ if (current.isStatic())
+ return true;
+ } while ((current = current.enclosingType()) != null);
+ return true;
+}
+
+// JLS3: 4.5.1.1
+public boolean isTypeArgumentContainedBy(TypeBinding otherArgument) {
+ if (this == otherArgument)
+ return true;
+ TypeBinding lowerBound = this;
+ TypeBinding upperBound = this;
+ if (isWildcard()) {
+ WildcardBinding wildcard = (WildcardBinding) this;
+ switch(wildcard.kind) {
+ case Wildcard.EXTENDS :
+ upperBound = wildcard.bound;
+ lowerBound = null;
+ break;
+ case Wildcard. SUPER :
+ upperBound = wildcard.typeVariable();
+ lowerBound = wildcard.bound;
+ break;
+ case Wildcard.UNBOUND :
+ upperBound = wildcard.typeVariable();
+ lowerBound = null;
+ }
+ }
+ if (otherArgument.isWildcard()) {
+ WildcardBinding otherWildcard = (WildcardBinding) otherArgument;
+ switch(otherWildcard.kind) {
+ case Wildcard.EXTENDS:
+ return upperBound != null && upperBound.isCompatibleWith(otherWildcard.bound);
+
+ case Wildcard.SUPER :
+ return lowerBound != null && otherWildcard.bound.isCompatibleWith(lowerBound);
+
+ case Wildcard.UNBOUND :
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Returns true if the type was declared as a type variable
+ */
+public boolean isTypeVariable() {
+ return false;
+}
+/**
+ * Returns true if wildcard type of the form '?' (no bound)
+ */
+public boolean isUnboundWildcard() {
+ return false;
+}
+
+/**
+ * Returns true if the type is a wildcard
+ */
+public boolean isWildcard() {
+ return false;
+}
+
+/**
+ * Meant to be invoked on compatible types, to figure if unchecked conversion is necessary
+ */
+public boolean needsUncheckedConversion(TypeBinding targetType) {
+ return false;
+}
+