KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.core.dom.ITypeBinding;
14
15 import org.eclipse.jdt.internal.corext.dom.Bindings;
16 import org.eclipse.jdt.internal.corext.dom.TypeRules;
17
18 public abstract class ConstraintVariable {
19     /**
20      * The type binding, or <code>null</code>.
21      */

22     private final ITypeBinding fTypeBinding;
23
24     /**
25      * @param binding the type binding, or <code>null</code>
26      */

27     protected ConstraintVariable(ITypeBinding binding) {
28         fTypeBinding= binding;
29     }
30
31     public boolean canBeAssignedTo(ConstraintVariable targetVariable) {
32         if (fTypeBinding == null || targetVariable.fTypeBinding == null)
33             return false;
34         return TypeRules.canAssign(fTypeBinding, targetVariable.fTypeBinding);
35     }
36
37     public String JavaDoc toResolvedString() {
38         if (fTypeBinding == null)
39             return "<NULL BINDING>"; //$NON-NLS-1$
40
return Bindings.asString(fTypeBinding);
41     }
42
43     /* (non-Javadoc)
44      * @see java.lang.Object#toString()
45      */

46     public String JavaDoc toString() {
47         return toResolvedString();
48     }
49         
50     /**
51      * @return the type binding or <code>null</code>
52      */

53     //TODO: rename to getTypeBinding()
54
public ITypeBinding getBinding() {
55         return fTypeBinding;
56     }
57
58     /**
59      * For storing additional information associated with constraint variables.
60      * Added in anticipation of the generics-related refactorings.
61      */

62     private Object JavaDoc fData;
63     
64     public Object JavaDoc getData(){
65         return fData;
66     }
67     
68     public void setData(Object JavaDoc data){
69         fData= data;
70     }
71 }
72
Popular Tags