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 org.eclipse.jdt.core.dom.ITypeBinding;
15 import org.eclipse.jdt.internal.corext.dom.Bindings;
16 import org.eclipse.jdt.internal.corext.dom.TypeRules;
18 public abstract class ConstraintVariable {
20 * The type binding, or <code>null</code>.
22 private final ITypeBinding fTypeBinding;
25 * @param binding the type binding, or <code>null</code>
27 protected ConstraintVariable(ITypeBinding binding) {
28 fTypeBinding= binding;
31 public boolean canBeAssignedTo(ConstraintVariable targetVariable) {
32 if (fTypeBinding == null || targetVariable.fTypeBinding == null)
34 return TypeRules.canAssign(fTypeBinding, targetVariable.fTypeBinding);
37 public String toResolvedString() {
38 if (fTypeBinding == null)
39 return "<NULL BINDING>"; //$NON-NLS-1$
40 return Bindings.asString(fTypeBinding);
44 * @see java.lang.Object#toString()
47 public String toString() {
48 return toResolvedString();
52 * @return the type binding or <code>null</code>
54 //TODO: rename to getTypeBinding()
55 public ITypeBinding getBinding() {
60 * For storing additional information associated with constraint variables.
61 * Added in anticipation of the generics-related refactorings.
65 public Object getData(){
69 public void setData(Object data){