]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/types/AbstractTypeVariable.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / core refactoring / org / eclipse / jdt / internal / corext / refactoring / typeconstraints / types / AbstractTypeVariable.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types;
12
13 import org.eclipse.jdt.core.dom.ITypeBinding;
14
15
16 public abstract class AbstractTypeVariable extends TType {
17
18         protected TType[] fBounds;
19
20         protected AbstractTypeVariable(TypeEnvironment environment) {
21                 super(environment);
22         }
23
24         @Override
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());
32                         }
33                 } else {
34                         fBounds= new TType[bounds.length];
35                         for (int i= 0; i < bounds.length; i++) {
36                                 fBounds[i]= getEnvironment().create(bounds[i]);
37                         }
38                 }
39         }
40
41         @Override
42         public TType getErasure() {
43                 if (fBounds.length == 0)
44                         return getEnvironment().getJavaLangObject();
45                 return fBounds[0].getErasure();
46         }
47
48         /* package */ final boolean isUnbounded() {
49                 if (fBounds.length == 0)
50                         return true;
51                 return fBounds[0].isJavaLangObject();
52         }
53
54         public final TType[] getBounds() {
55                 return fBounds.clone();
56         }
57
58         @Override
59         public final TType[] getSubTypes() {
60                 return EMPTY_TYPE_ARRAY;
61         }
62
63         protected final boolean checkAssignmentBound(TType rhs) {
64                 if (fBounds.length == 0)
65                         return true;
66                 for (int i= 0; i < fBounds.length; i++) {
67                         if (rhs.canAssignTo(fBounds[i]))
68                                 return true;
69                 }
70                 return false;
71         }
72
73         protected final boolean canAssignOneBoundTo(TType lhs) {
74                 return lhs.generated_5597156020101478984(this);
75         }
76
77 }