Methods Summary |
---|
public boolean | equals(java.lang.Object o)
if(!(o instanceof TypeVariable)) {
return false;
}
TypeVariable<?> that = (TypeVariable<?>) o;
return getName().equals(that.getName()) &&
getGenericDeclaration().equals(that.getGenericDeclaration());
|
static java.lang.reflect.TypeVariable | findFormalVar(java.lang.reflect.GenericDeclaration layer, java.lang.String name)
TypeVariable[] formalVars = layer.getTypeParameters();
for (TypeVariable var : formalVars) {
if (name.equals(var.getName())) {
return var;
}
}
// resolve() looks up the next level only, if null is returned
return null;
|
public java.lang.reflect.Type[] | getBounds()
resolve();
return bounds.getResolvedTypes().clone();
|
public D | getGenericDeclaration()
resolve();
return genericDeclaration;
|
public java.lang.String | getName()
return name;
|
public int | hashCode()
return 31 * getName().hashCode() + getGenericDeclaration().hashCode();
|
static java.lang.reflect.GenericDeclaration | nextLayer(java.lang.reflect.GenericDeclaration decl)
if (decl instanceof Class) {
// FIXME: Is the following hierarchy correct?:
Class cl = (Class)decl;
decl = cl.getEnclosingMethod();
if (decl != null) {
return decl;
}
decl = cl.getEnclosingConstructor();
if (decl != null) {
return decl;
}
return cl.getEnclosingClass();
} else if (decl instanceof Method) {
return ((Method)decl).getDeclaringClass();
} else if (decl instanceof Constructor) {
return ((Constructor)decl).getDeclaringClass();
}
throw new RuntimeException("unknown GenericDeclaration2: "
+ decl.toString());
|
void | resolve()
if (formalVar == null) {
GenericDeclaration curLayer = declOfVarUser;
TypeVariable var = null;
do {
var = findFormalVar(curLayer, name);
if (var != null) break;
else {
curLayer = nextLayer(curLayer);
if (curLayer == null) break; // FIXME: SHOULD NEVER HAPPEN!
// throw exception: illegal
// type variable reference.
}
} while (true);
formalVar = (ImplForVariable<D>)var;
this.genericDeclaration = formalVar.genericDeclaration;
this.bounds = formalVar.bounds;
}
|
public java.lang.String | toString()
return name;
|