1 11 package org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jdt.core.IType; 16 import org.eclipse.jdt.core.dom.ITypeBinding; 17 18 19 public final class RawType extends HierarchyType { 20 21 private HierarchyType fTypeDeclaration; 22 23 protected RawType(TypeEnvironment environment) { 24 super(environment); 25 } 26 27 protected void initialize(ITypeBinding binding, IType javaElementType) { 28 Assert.isTrue(binding.isRawType()); 29 super.initialize(binding, javaElementType); 30 TypeEnvironment environment= getEnvironment(); 31 fTypeDeclaration= (HierarchyType)environment.create(binding.getTypeDeclaration()); 32 } 33 34 public int getKind() { 35 return RAW_TYPE; 36 } 37 38 public boolean doEquals(TType type) { 39 return getJavaElementType().equals(((RawType)type).getJavaElementType()); 40 } 41 42 public int hashCode() { 43 return getJavaElementType().hashCode(); 44 } 45 46 public TType getTypeDeclaration() { 47 return fTypeDeclaration; 48 } 49 50 public TType getErasure() { 51 return fTypeDeclaration; 52 } 53 54 HierarchyType getHierarchyType() { 55 return fTypeDeclaration; 56 } 57 58 protected boolean doCanAssignTo(TType lhs) { 59 int targetType= lhs.getKind(); 60 switch (targetType) { 61 case NULL_TYPE: return false; 62 case VOID_TYPE: return false; 63 case PRIMITIVE_TYPE: return false; 64 65 case ARRAY_TYPE: return false; 66 67 case STANDARD_TYPE: return canAssignToStandardType((StandardType)lhs); 68 case GENERIC_TYPE: return false; 69 case PARAMETERIZED_TYPE: return isSubType((ParameterizedType)lhs); 70 case RAW_TYPE: return isSubType((HierarchyType)lhs); 71 72 case UNBOUND_WILDCARD_TYPE: 73 case SUPER_WILDCARD_TYPE: 74 case EXTENDS_WILDCARD_TYPE: 75 return ((WildcardType)lhs).checkAssignmentBound(this); 76 77 case TYPE_VARIABLE: return false; 78 case CAPTURE_TYPE: 79 return ((CaptureType)lhs).checkLowerBound(this); 80 } 81 return false; 82 } 83 84 protected boolean isTypeEquivalentTo(TType other) { 85 int otherElementType= other.getKind(); 86 if (otherElementType == PARAMETERIZED_TYPE || otherElementType == GENERIC_TYPE) 87 return getErasure().isTypeEquivalentTo(other.getErasure()); 88 return super.isTypeEquivalentTo(other); 89 } 90 91 public String getName() { 92 return getJavaElementType().getElementName(); 93 } 94 95 protected String getPlainPrettySignature() { 96 return getJavaElementType().getFullyQualifiedName('.'); 97 } 98 } 99 | Popular Tags |