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.dom.ITypeBinding; 16 17 18 public abstract class WildcardType extends TType { 19 protected TType fBound; 20 21 protected WildcardType(TypeEnvironment environment) { 22 super(environment); 23 } 24 25 protected void initialize(ITypeBinding binding) { 26 Assert.isTrue(binding.isWildcardType()); 27 super.initialize(binding); 28 ITypeBinding bound= binding.getBound(); 29 if (bound != null) { 30 fBound= getEnvironment().create(bound); 31 } 32 } 33 34 public TType getBound() { 35 return fBound; 36 } 37 38 public TType[] getSubTypes() { 39 throw new UnsupportedOperationException (); 40 } 41 42 public boolean doEquals(TType type) { 43 WildcardType other= (WildcardType)type; 44 if (fBound == null) 45 return other.fBound == null; 46 return fBound.equals(other.fBound); 47 } 48 49 public int hashCode() { 50 if (fBound == null) 51 return super.hashCode(); 52 return fBound.hashCode() << WILDCARD_TYPE_SHIFT; 53 } 54 55 protected abstract boolean checkAssignmentBound(TType rhs); 56 57 59 protected String internalGetName(String keyword) { 60 StringBuffer result= new StringBuffer ("?"); TType bound= getBound(); 62 if (bound != null) { 63 result.append(" "); result.append(keyword); 65 result.append(" "); result.append(bound.getName()); 67 } 68 return result.toString(); 69 } 70 71 protected String internalGetPrettySignature(String keyword) { 72 StringBuffer result= new StringBuffer ("?"); TType bound= getBound(); 74 if (bound != null) { 75 result.append(" "); result.append(keyword); 77 result.append(" "); result.append(bound.getPlainPrettySignature()); 79 } 80 return result.toString(); 81 } 82 } 83 | Popular Tags |