Example usage for org.eclipse.jdt.internal.compiler.lookup TagBits HasDirectWildcard

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TagBits HasDirectWildcard

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup TagBits HasDirectWildcard.

Prototype

long HasDirectWildcard

To view the source code for org.eclipse.jdt.internal.compiler.lookup TagBits HasDirectWildcard.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

/**
 * Returns true if a type is identical to another one,
 * or for generic types, true if compared to its raw type.
 *//*from ww w .j a  v a2  s  .  c o m*/
public boolean isEquivalentTo(TypeBinding otherType) {

    if (this == otherType)
        return true;
    if (otherType == null)
        return false;
    switch (otherType.kind()) {

    case Binding.WILDCARD_TYPE:
    case Binding.INTERSECTION_TYPE:
        return ((WildcardBinding) otherType).boundCheck(this);

    case Binding.PARAMETERIZED_TYPE:
        if ((otherType.tagBits & TagBits.HasDirectWildcard) == 0
                && (!isMemberType() || !otherType.isMemberType()))
            return false; // should have been identical
        ParameterizedTypeBinding otherParamType = (ParameterizedTypeBinding) otherType;
        if (this != otherParamType.genericType())
            return false;
        if (!isStatic()) { // static member types do not compare their enclosing
            ReferenceBinding enclosing = enclosingType();
            if (enclosing != null) {
                ReferenceBinding otherEnclosing = otherParamType.enclosingType();
                if (otherEnclosing == null)
                    return false;
                if ((otherEnclosing.tagBits & TagBits.HasDirectWildcard) == 0) {
                    if (enclosing != otherEnclosing)
                        return false;
                } else {
                    if (!enclosing.isEquivalentTo(otherParamType.enclosingType()))
                        return false;
                }
            }
        }
        int length = this.typeVariables == null ? 0 : this.typeVariables.length;
        TypeBinding[] otherArguments = otherParamType.arguments;
        int otherLength = otherArguments == null ? 0 : otherArguments.length;
        if (otherLength != length)
            return false;
        for (int i = 0; i < length; i++)
            if (!this.typeVariables[i].isTypeArgumentContainedBy(otherArguments[i]))
                return false;
        return true;

    case Binding.RAW_TYPE:
        return otherType.erasure() == this;
    }
    return false;
}