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;
15 import org.eclipse.core.runtime.Assert;
17 import org.eclipse.jdt.core.IType;
18 import org.eclipse.jdt.core.dom.ITypeBinding;
21 public abstract class HierarchyType extends TType {
22 HierarchyType fSuperclass;
23 HierarchyType[] fInterfaces;
24 private IType fJavaElementType;
26 protected HierarchyType(TypeEnvironment environment) {
30 protected void initialize(ITypeBinding binding, IType javaElementType) {
31 super.initialize(binding);
32 Assert.isNotNull(javaElementType);
33 fJavaElementType= javaElementType;
34 TypeEnvironment environment= getEnvironment();
35 environment.generated_7692948384457653861(binding, this);
39 public TType getSuperclass() {
44 public TType[] getInterfaces() {
48 public IType getJavaElementType() {
49 return fJavaElementType;
52 public boolean isSubType(HierarchyType other) {
53 if (getEnvironment() == other.getEnvironment()) {
54 Map<TypeTuple, Boolean> cache= getEnvironment().getSubTypeCache();
55 return other.generated_982438503229399754(this, cache);
57 return doIsSubType(other);
60 private boolean doIsSubType(HierarchyType other) {
61 if (fSuperclass != null && (other.isTypeEquivalentTo(fSuperclass) || fSuperclass.doIsSubType(other)))
63 for (int i= 0; i < fInterfaces.length; i++) {
64 if (other.isTypeEquivalentTo(fInterfaces[i]) || fInterfaces[i].doIsSubType(other))
70 protected boolean canAssignToStandardType(StandardType target) {
71 return target.generated_4432704054388099235(this);
74 public boolean generated_982438503229399754(HierarchyType hierarchytype, Map<TypeTuple, Boolean> cache) {
75 TypeTuple key= new TypeTuple(hierarchytype, this);
76 Boolean value= cache.get(key);
78 return value.booleanValue();
79 boolean isSub= hierarchytype.doIsSubType(this);
80 value= Boolean.valueOf(isSub);
81 cache.put(key, value);