1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints2;
13 import org.eclipse.core.runtime.Assert;
15 public final class SubTypeConstraint2 implements ITypeConstraint2 {
17 private final ConstraintVariable2 fAncestor;
19 private final ConstraintVariable2 fDescendant;
21 public SubTypeConstraint2(final ConstraintVariable2 descendant, final ConstraintVariable2 ancestor) {
22 Assert.isNotNull(descendant);
23 Assert.isNotNull(ancestor);
24 fDescendant= descendant;
29 * @see java.lang.Object#equals(java.lang.Object)
32 public final boolean equals(Object other) {
33 // can use object identity on ConstraintVariables, since we have the stored (or to be stored) objects
34 if (other.getClass() != SubTypeConstraint2.class)
37 ITypeConstraint2 otherTC= (ITypeConstraint2) other;
38 return fDescendant == otherTC.getLeft() && fAncestor == otherTC.getRight();
41 public final ConstraintVariable2 getLeft() {
45 public final ConstraintVariable2 getRight() {
50 * @see java.lang.Object#hashCode()
53 public final int hashCode() {
54 return fDescendant.hashCode() ^ 37 * fAncestor.hashCode();
58 * @see java.lang.Object#toString()
61 public final String toString() {
62 return fDescendant.toString() + " <= " + fAncestor.toString(); //$NON-NLS-1$