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.typeconstraints;
13 import java.util.Collection;
15 import org.eclipse.core.runtime.Assert;
17 import org.eclipse.jdt.core.dom.ITypeBinding;
19 import org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring;
21 public final class SimpleTypeConstraint implements ITypeConstraint {
23 private final ConstraintVariable fLeft;
24 private final ConstraintVariable fRight;
25 private final ConstraintOperator fOperator;
27 /* package */ SimpleTypeConstraint(ConstraintVariable left, ConstraintVariable right, ConstraintOperator operator) {
28 Assert.isNotNull(left);
29 Assert.isNotNull(right);
30 Assert.isNotNull(operator);
36 public ConstraintVariable getLeft() {
40 public ConstraintVariable getRight() {
44 public ConstraintOperator getOperator() {
49 * @see java.lang.Object#toString()
52 public String toString(){
53 return getLeft().toString() + " " + fOperator.toString() + " " + getRight().toString(); //$NON-NLS-1$ //$NON-NLS-2$
57 * @see org.eclipse.jdt.internal.corext.refactoring.experiments.TypeConstraint#toResolvedString()
59 public String toResolvedString() {
60 return getLeft().toResolvedString() + " " + fOperator.toString() + " " + getRight().toResolvedString(); //$NON-NLS-1$ //$NON-NLS-2$
64 * @see org.eclipse.jdt.internal.corext.refactoring.experiments.ITypeConstraint#isSimpleTypeConstraint()
66 public boolean isSimpleTypeConstraint() {
70 public boolean isSubtypeConstraint(){
71 return fOperator.isSubtypeOperator();
74 public boolean isStrictSubtypeConstraint(){
75 return fOperator.isStrictSubtypeOperator();
78 public boolean isEqualsConstraint(){
79 return fOperator.isEqualsOperator();
82 public boolean isDefinesConstraint(){
83 return fOperator.isDefinesOperator();
86 public void generated_7576130079388084015(Collection<ConstraintVariable> relevantConstraintVars, Collection<ITypeConstraint> result, ITypeConstraint tc) {
87 if (relevantConstraintVars.contains(getLeft()) || relevantConstraintVars.contains(getRight()))
91 public boolean generated_4288874648754587294(ITypeBinding type, Collection<ConstraintVariable> relevantVars, ChangeTypeRefactoring changetyperefactoring) {
92 if (relevantVars.contains(getLeft())) { // upper bound
93 if (!changetyperefactoring.isSubTypeOf(type, changetyperefactoring.findType(getRight()))) {