1 11 12 package org.eclipse.jdt.internal.compiler.apt.model; 13 14 import javax.lang.model.element.Element; 15 import javax.lang.model.type.TypeKind; 16 import javax.lang.model.type.TypeMirror; 17 import javax.lang.model.type.TypeVariable; 18 import javax.lang.model.type.TypeVisitor; 19 20 import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl; 21 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; 22 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 23 import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; 24 25 29 public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable { 30 31 public TypeVariableImpl(BaseProcessingEnvImpl env, TypeVariableBinding binding) { 32 super(env, binding); 33 } 34 37 @Override 38 public Element asElement() { 39 return _env.getFactory().newElement(this._binding); 40 } 41 42 45 @Override 46 public TypeMirror getLowerBound() { 47 return this._env.getFactory().getNullType(); 49 } 50 51 54 @Override 55 public TypeMirror getUpperBound() { 56 TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this._binding; 57 TypeBinding firstBound = typeVariableBinding.firstBound; 58 ReferenceBinding[] superInterfaces = typeVariableBinding.superInterfaces; 59 if (firstBound == null || superInterfaces.length == 0) { 60 return _env.getFactory().newTypeMirror(typeVariableBinding.upperBound()); 62 } 63 if (firstBound != null && superInterfaces.length == 1 && superInterfaces[0] == firstBound) { 64 return _env.getFactory().newTypeMirror(typeVariableBinding.upperBound()); 66 } 67 return this._env.getFactory().newDeclaredType((TypeVariableBinding) this._binding); 68 } 69 70 73 @Override 74 public <R, P> R accept(TypeVisitor<R, P> v, P p) { 75 return v.visitTypeVariable(this, p); 76 } 77 78 @Override 79 public TypeKind getKind() 80 { 81 return TypeKind.TYPEVAR; 82 } 83 84 85 } 86 | Popular Tags |