1 11 12 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints2; 13 14 import org.eclipse.core.runtime.Assert; 15 16 import org.eclipse.jdt.core.ICompilationUnit; 17 18 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.CompilationUnitRange; 19 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; 20 21 25 public final class TypeVariable2 extends ConstraintVariable2 implements ITypeConstraintVariable { 26 27 private final CompilationUnitRange fRange; 28 29 public TypeVariable2(TType type, CompilationUnitRange range) { 30 super(type); 31 Assert.isNotNull(range); 32 fRange= range; 33 } 34 35 public CompilationUnitRange getRange() { 36 return fRange; 37 } 38 39 42 public int hashCode() { 43 return getRange().hashCode() ^ getType().hashCode(); 44 } 45 46 49 public boolean equals(Object other) { 50 if (this == other) 52 return true; 53 if (other.getClass() != TypeVariable2.class) 54 return false; 55 56 TypeVariable2 otherTypeVariable= (TypeVariable2) other; 57 return getRange().equals(otherTypeVariable.getRange()) 58 && getType() == otherTypeVariable.getType(); 59 } 60 61 public void setCompilationUnit(ICompilationUnit unit) { 62 throw new UnsupportedOperationException (); 63 } 64 65 public ICompilationUnit getCompilationUnit() { 66 return fRange.getCompilationUnit(); 67 } 68 69 public String toString() { 70 return super.toString() + " [" + fRange.getSourceRange().getOffset() + '+' + fRange.getSourceRange().getLength() + ']'; } 72 } 73 | Popular Tags |