package org.eclipse.jdt.internal.compiler.lookup;
public class TypeBound extends ReductionResult {
InferenceVariable left;
boolean isSoft;
long nullHints;
static TypeBound createBoundOrDependency(InferenceSubstitution theta, TypeBinding type, InferenceVariable variable) {
return new TypeBound(variable, theta.substitute(theta, type), SUBTYPE, true);
}
TypeBound(InferenceVariable inferenceVariable, TypeBinding typeBinding, int relation) {
this(inferenceVariable, typeBinding, relation, false);
}
TypeBound(InferenceVariable inferenceVariable, TypeBinding typeBinding, int relation, boolean isSoft) {
this.left = inferenceVariable;
this.right = typeBinding;
if (((inferenceVariable.tagBits | this.right.tagBits) & TagBits.AnnotationNullMASK) != 0) {
if ((inferenceVariable.tagBits & TagBits.AnnotationNullMASK) == (this.right.tagBits & TagBits.AnnotationNullMASK)) {
this.left = (InferenceVariable) inferenceVariable.withoutToplevelNullAnnotation();
this.right = this.right.withoutToplevelNullAnnotation();
} else {
long mask = 0;
switch (relation) {
case SAME: mask = TagBits.AnnotationNullMASK; break;
case SUBTYPE: mask = TagBits.AnnotationNonNull; break;
case SUPERTYPE: mask = TagBits.AnnotationNullable; break;
}
inferenceVariable.prototype().nullHints |= this.right.tagBits & mask;
}
}
this.relation = relation;
this.isSoft = isSoft;
}
boolean isBound() {
return this.right.isProperType(true);
}
@Override
public int hashCode() {
return this.left.hashCode() + this.right.hashCode() + this.relation;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof TypeBound) {
TypeBound other = (TypeBound) obj;
return (this.relation == other.relation) && TypeBinding.equalsEquals(this.left, other.left) && TypeBinding.equalsEquals(this.right, other.right);
}
return false;
}
@Override
public String toString() {
boolean isBound = this.right.isProperType(true);
StringBuffer buf = new StringBuffer();
buf.append(isBound ? "TypeBound " : "Dependency ");
buf.append(this.left.sourceName);
buf.append(relationToString(this.relation));
buf.append(this.right.readableName());
return buf.toString();
}
}