KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > refactoring > typeconstraints > SimpleTypeConstraint


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 org.eclipse.core.runtime.Assert;
14
15 public final class SimpleTypeConstraint implements ITypeConstraint {
16     
17     private final ConstraintVariable fLeft;
18     private final ConstraintVariable fRight;
19     private final ConstraintOperator fOperator;
20     
21     /* package */ SimpleTypeConstraint(ConstraintVariable left, ConstraintVariable right, ConstraintOperator operator) {
22         Assert.isNotNull(left);
23         Assert.isNotNull(right);
24         Assert.isNotNull(operator);
25         fLeft= left;
26         fRight= right;
27         fOperator= operator;
28     }
29     
30     public ConstraintVariable getLeft() {
31         return fLeft;
32     }
33
34     public ConstraintVariable getRight() {
35         return fRight;
36     }
37
38     public ConstraintOperator getOperator() {
39         return fOperator;
40     }
41
42     /* (non-Javadoc)
43      * @see java.lang.Object#toString()
44      */

45     public String JavaDoc toString(){
46         return getLeft().toString() + " " + fOperator.toString() + " " + getRight().toString(); //$NON-NLS-1$ //$NON-NLS-2$
47
}
48
49     /* (non-Javadoc)
50      * @see org.eclipse.jdt.internal.corext.refactoring.experiments.TypeConstraint#toResolvedString()
51      */

52     public String JavaDoc toResolvedString() {
53         return getLeft().toResolvedString() + " " + fOperator.toString() + " " + getRight().toResolvedString(); //$NON-NLS-1$ //$NON-NLS-2$
54
}
55
56     /* (non-Javadoc)
57      * @see org.eclipse.jdt.internal.corext.refactoring.experiments.ITypeConstraint#isSimpleTypeConstraint()
58      */

59     public boolean isSimpleTypeConstraint() {
60         return true;
61     }
62     
63     public boolean isSubtypeConstraint(){
64         return fOperator.isSubtypeOperator();
65     }
66
67     public boolean isStrictSubtypeConstraint(){
68         return fOperator.isStrictSubtypeOperator();
69     }
70
71     public boolean isEqualsConstraint(){
72         return fOperator.isEqualsOperator();
73     }
74
75     public boolean isDefinesConstraint(){
76         return fOperator.isDefinesOperator();
77     }
78 }
79
Popular Tags