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.types;
13 import org.eclipse.jdt.core.dom.ITypeBinding;
16 public abstract class AbstractTypeVariable extends TType {
18 protected TType[] fBounds;
20 protected AbstractTypeVariable(TypeEnvironment environment) {
25 protected void initialize(ITypeBinding binding) {
26 super.initialize(binding);
27 ITypeBinding[] bounds= binding.getTypeBounds();
28 if (bounds.length == 0) {
29 fBounds= EMPTY_TYPE_ARRAY;
30 if (getEnvironment().getJavaLangObject() == null) {
31 getEnvironment().initializeJavaLangObject(binding.getErasure());
34 fBounds= new TType[bounds.length];
35 for (int i= 0; i < bounds.length; i++) {
36 fBounds[i]= getEnvironment().create(bounds[i]);
42 public TType getErasure() {
43 if (fBounds.length == 0)
44 return getEnvironment().getJavaLangObject();
45 return fBounds[0].getErasure();
48 /* package */ final boolean isUnbounded() {
49 if (fBounds.length == 0)
51 return fBounds[0].isJavaLangObject();
54 public final TType[] getBounds() {
55 return fBounds.clone();
59 public final TType[] getSubTypes() {
60 return EMPTY_TYPE_ARRAY;
63 protected final boolean checkAssignmentBound(TType rhs) {
64 if (fBounds.length == 0)
66 for (int i= 0; i < fBounds.length; i++) {
67 if (rhs.canAssignTo(fBounds[i]))
73 protected final boolean canAssignOneBoundTo(TType lhs) {
74 return lhs.generated_5597156020101478984(this);