]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/SimpleTypeConstraint.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / core refactoring / org / eclipse / jdt / internal / corext / refactoring / typeconstraints / SimpleTypeConstraint.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints;
12
13 import java.util.Collection;
14
15 import org.eclipse.core.runtime.Assert;
16
17 import org.eclipse.jdt.core.dom.ITypeBinding;
18
19 import org.eclipse.jdt.internal.corext.refactoring.structure.ChangeTypeRefactoring;
20
21 public final class SimpleTypeConstraint implements ITypeConstraint {
22
23         private final ConstraintVariable fLeft;
24         private final ConstraintVariable fRight;
25         private final ConstraintOperator fOperator;
26
27         /* package */ SimpleTypeConstraint(ConstraintVariable left, ConstraintVariable right, ConstraintOperator operator) {
28                 Assert.isNotNull(left);
29                 Assert.isNotNull(right);
30                 Assert.isNotNull(operator);
31                 fLeft= left;
32                 fRight= right;
33                 fOperator= operator;
34         }
35
36         public  ConstraintVariable getLeft() {
37                 return fLeft;
38         }
39
40         public  ConstraintVariable getRight() {
41                 return fRight;
42         }
43
44         public ConstraintOperator getOperator() {
45                 return fOperator;
46         }
47
48         /* (non-Javadoc)
49          * @see java.lang.Object#toString()
50          */
51         @Override
52         public  String toString(){
53                 return getLeft().toString() + " " + fOperator.toString() + " " + getRight().toString(); //$NON-NLS-1$ //$NON-NLS-2$
54         }
55
56         /* (non-Javadoc)
57          * @see org.eclipse.jdt.internal.corext.refactoring.experiments.TypeConstraint#toResolvedString()
58          */
59         public  String toResolvedString() {
60                 return getLeft().toResolvedString() + " " + fOperator.toString() + " " + getRight().toResolvedString(); //$NON-NLS-1$ //$NON-NLS-2$
61         }
62
63         /* (non-Javadoc)
64          * @see org.eclipse.jdt.internal.corext.refactoring.experiments.ITypeConstraint#isSimpleTypeConstraint()
65          */
66         public  boolean isSimpleTypeConstraint() {
67                 return true;
68         }
69
70         public boolean isSubtypeConstraint(){
71                 return fOperator.isSubtypeOperator();
72         }
73
74         public boolean isStrictSubtypeConstraint(){
75                 return fOperator.isStrictSubtypeOperator();
76         }
77
78         public boolean isEqualsConstraint(){
79                 return fOperator.isEqualsOperator();
80         }
81
82         public boolean isDefinesConstraint(){
83                 return fOperator.isDefinesOperator();
84         }
85
86         public void generated_7576130079388084015(Collection<ConstraintVariable> relevantConstraintVars, Collection<ITypeConstraint> result, ITypeConstraint tc) {
87                 if (relevantConstraintVars.contains(getLeft()) || relevantConstraintVars.contains(getRight()))
88                         result.add(tc);
89         }
90
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()))) {
94                                 return false;
95                         }
96                 }
97                 return true;
98         }
99 }