1 32 package net.sf.retrotranslator.runtime.impl; 33 34 import java.lang.reflect.*; 35 import net.sf.retrotranslator.runtime.asm.signature.SignatureVisitor; 36 37 40 public abstract class GenericDeclarationDescriptor extends AnnotatedElementDescriptor { 41 42 private LazyList<TypeParameter, TypeVariable> typeParameters = new LazyList<TypeParameter, TypeVariable>() { 43 44 protected TypeVariable resolve(TypeParameter input) { 45 return new TypeVariableImpl(getTarget(), input.name, input.bounds); 46 } 47 48 protected TypeVariable[] newArray(int size) { 49 return new TypeVariable[size]; 50 } 51 }; 52 53 protected TypeVariable getTypeVariable(String name) { 54 for (TypeVariable variable : typeParameters.getLive()) { 55 if (name.equals(variable.getName())) return variable; 56 } 57 return null; 58 } 59 60 public abstract GenericDeclaration getTarget(); 61 62 public TypeVariable[] getTypeParameters() { 63 return typeParameters.getClone(); 64 } 65 66 public void visitFormalTypeParameter(String name) { 67 typeParameters.add(new TypeParameter(name, getLazyList())); 68 } 69 70 public SignatureVisitor visitClassBound() { 71 TypeDescriptor descriptor = new TypeDescriptor(); 72 typeParameters.getLast().bounds.add(descriptor); 73 return descriptor; 74 } 75 76 public SignatureVisitor visitInterfaceBound() { 77 TypeDescriptor descriptor = new TypeDescriptor(); 78 typeParameters.getLast().bounds.add(descriptor); 79 return descriptor; 80 } 81 82 } | Popular Tags |