1 11 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints2; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jdt.core.ICompilationUnit; 16 import org.eclipse.jdt.core.dom.IMethodBinding; 17 18 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; 19 20 24 public final class ParameterTypeVariable2 extends ConstraintVariable2 implements ISourceConstraintVariable { 25 26 private final int fParameterIndex; 27 private final String fKey; 28 private ICompilationUnit fCompilationUnit; 29 30 public ParameterTypeVariable2(TType type, int index, IMethodBinding binding) { 31 super(type); 32 Assert.isNotNull(binding); 33 Assert.isTrue(0 <= index); 34 fParameterIndex= index; 35 fKey= binding.getKey(); 36 } 37 38 public void setCompilationUnit(ICompilationUnit cu) { 39 fCompilationUnit= cu; 40 } 41 42 public ICompilationUnit getCompilationUnit() { 43 return fCompilationUnit; 44 } 45 46 public int getParameterIndex() { 47 return fParameterIndex; 48 } 49 50 public String getKey() { 51 return fKey; 52 } 53 54 57 public int hashCode() { 58 return getParameterIndex() ^ getKey().hashCode(); 59 } 60 61 64 public boolean equals(Object other) { 65 if (this == other) 66 return true; 67 if (other.getClass() != ParameterTypeVariable2.class) 68 return false; 69 70 ParameterTypeVariable2 other2= (ParameterTypeVariable2) other; 71 return getParameterIndex() == other2.getParameterIndex() 72 && getKey().equals(other2.getKey()); 73 } 74 75 public String toString() { 76 String toString= (String ) getData(TO_STRING); 77 return toString == null ? "[Parameter(" + fParameterIndex + "," + fKey + ")]" : toString; } 79 } 80 | Popular Tags |