1 11 12 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints2; 13 14 import org.eclipse.jdt.core.ICompilationUnit; 15 import org.eclipse.jdt.core.dom.ITypeBinding; 16 17 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TypeVariable; 18 19 public final class CollectionElementVariable2 extends ConstraintVariable2 { 20 21 public static final int NOT_DECLARED_TYPE_VARIABLE_INDEX= -1; 22 23 private final ConstraintVariable2 fParentCv; 24 private final String fTypeVariableKey; 25 private final int fDeclarationTypeVariableIndex; 26 27 34 public CollectionElementVariable2(ConstraintVariable2 parentCv, ITypeBinding typeVariable, int declarationTypeVariableIndex) { 35 super(null); 36 fParentCv= parentCv; 37 if (! typeVariable.isTypeVariable()) 38 throw new IllegalArgumentException (typeVariable.toString()); 39 fTypeVariableKey= typeVariable.getKey(); 40 fDeclarationTypeVariableIndex= declarationTypeVariableIndex; 41 } 42 43 public CollectionElementVariable2(ConstraintVariable2 parentCv, TypeVariable typeVariable, int declarationTypeVariableIndex) { 44 super(null); 45 fParentCv= parentCv; 46 fTypeVariableKey= typeVariable.getBindingKey(); 47 fDeclarationTypeVariableIndex= declarationTypeVariableIndex; 48 } 49 50 53 public int hashCode() { 54 return fParentCv.hashCode() ^ fTypeVariableKey.hashCode(); 55 } 56 57 60 public boolean equals(Object other) { 61 if (this == other) 62 return true; 63 if (other.getClass() != CollectionElementVariable2.class) 64 return false; 65 66 CollectionElementVariable2 other2= (CollectionElementVariable2) other; 67 return fParentCv == other2.fParentCv 68 && fTypeVariableKey.equals(other2.fTypeVariableKey); 69 } 70 71 public int getDeclarationTypeVariableIndex() { 72 return fDeclarationTypeVariableIndex; 73 } 74 75 public ConstraintVariable2 getParentConstraintVariable() { 76 return fParentCv; 77 } 78 79 public ICompilationUnit getCompilationUnit() { 80 if (fParentCv instanceof ISourceConstraintVariable) 81 return ((ISourceConstraintVariable) fParentCv).getCompilationUnit(); 82 else 83 return null; 84 } 87 88 public String toString() { 89 return "Elem[" + fParentCv.toString() + ", " + fTypeVariableKey + "]"; } 91 } 92 | Popular Tags |