1 11 package org.eclipse.jdt.internal.corext.refactoring.structure.constraints; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2; 16 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ITypeConstraint2; 17 18 21 public final class CovariantTypeConstraint implements ITypeConstraint2 { 22 23 24 private final ConstraintVariable2 fAncestor; 25 26 27 private final ConstraintVariable2 fDescendant; 28 29 35 public CovariantTypeConstraint(final ConstraintVariable2 descendant, final ConstraintVariable2 ancestor) { 36 Assert.isNotNull(descendant); 37 Assert.isNotNull(ancestor); 38 fDescendant= descendant; 39 fAncestor= ancestor; 40 } 41 42 45 public final boolean equals(final Object object) { 46 if (object.getClass() != CovariantTypeConstraint.class) 47 return false; 48 final ITypeConstraint2 other= (ITypeConstraint2) object; 49 return getLeft() == other.getLeft() && getRight() == other.getRight(); 50 } 51 52 55 public final ConstraintVariable2 getLeft() { 56 return fDescendant; 57 } 58 59 62 public final ConstraintVariable2 getRight() { 63 return fAncestor; 64 } 65 66 69 public final int hashCode() { 70 return fDescendant.hashCode() ^ 35 * fAncestor.hashCode(); 71 } 72 73 76 public final String toString() { 77 return fDescendant.toString() + " <<= " + fAncestor.toString(); } 79 } 80 | Popular Tags |