01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.corext.refactoring.typeconstraints;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: public final class SimpleTypeConstraint implements ITypeConstraint {
15:
16: private final ConstraintVariable fLeft;
17: private final ConstraintVariable fRight;
18: private final ConstraintOperator fOperator;
19:
20: /* package */SimpleTypeConstraint(ConstraintVariable left,
21: 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 toString() {
46: return getLeft().toString()
47: + " " + fOperator.toString() + " " + getRight().toString(); //$NON-NLS-1$ //$NON-NLS-2$
48: }
49:
50: /* (non-Javadoc)
51: * @see org.eclipse.jdt.internal.corext.refactoring.experiments.TypeConstraint#toResolvedString()
52: */
53: public String toResolvedString() {
54: return getLeft().toResolvedString()
55: + " " + fOperator.toString() + " " + getRight().toResolvedString(); //$NON-NLS-1$ //$NON-NLS-2$
56: }
57:
58: /* (non-Javadoc)
59: * @see org.eclipse.jdt.internal.corext.refactoring.experiments.ITypeConstraint#isSimpleTypeConstraint()
60: */
61: public boolean isSimpleTypeConstraint() {
62: return true;
63: }
64:
65: public boolean isSubtypeConstraint() {
66: return fOperator.isSubtypeOperator();
67: }
68:
69: public boolean isStrictSubtypeConstraint() {
70: return fOperator.isStrictSubtypeOperator();
71: }
72:
73: public boolean isEqualsConstraint() {
74: return fOperator.isEqualsOperator();
75: }
76:
77: public boolean isDefinesConstraint() {
78: return fOperator.isDefinesOperator();
79: }
80: }
|