*/
public static TypeVariable findTypeVariable(String typeVariableName, Object startPoint) {
// XXX: redesign after debugging to join all the common places below:
if (startPoint instanceof Field) {
Class klass = ((Field)startPoint).getDeclaringClass();
TypeVariable va[] = klass.getTypeParameters();
if (va != null) {
for(int i = 0; i < va.length; i++){
if(va[i].getName().equals(typeVariableName)){
/**/if (TypeVariableRepository.findTypeVariable(typeVariableName, klass) == null) { // Yes, it may be very inefficient now (for example, klass.getTypeParameters() invokation above can just registry a TV but we need to recheck it in this line) but
/**/ // after all the TV-repository's functionality implementation
/**/ // it will be time to improvement.
/**/ TypeVariableRepository.registerTypeVariable(va[i], typeVariableName, klass); // So, it was placed in repository just after an TV-instance creation but then
/**/ // it was removed (since we did not find it into the invoking method of this method look there at line with
/**/ // TypeVariableRepository.findTypeVariable(...) method invokation and also we did not find it in just above if-condition).
/**/ // As a consequence, we should reregistry it again as long as it become so popular again
/**/}
return va[i];
}
}
}
while (klass != null) {
klass = klass.getDeclaringClass();
/**/java.lang.reflect.TypeVariable variable = TypeVariableRepository.findTypeVariable(typeVariableName, klass);
/**/if (variable != null) {
/**/ return variable;
/**/}
va = klass.getTypeParameters();
if (va != null) {
for(int i = 0; i < va.length; i++){
if(va[i].getName().equals(typeVariableName)) {
/**/if (TypeVariableRepository.findTypeVariable(typeVariableName, klass) == null) { // Yes, it may be very inefficient now (for example, klass.getTypeParameters() invokation above can just registry a TV but we need to recheck it in this line) but
/**/ // after all the TV-repository's functionality implementation
/**/ // it will be time to improvement.
/**/ TypeVariableRepository.registerTypeVariable(va[i], typeVariableName, klass); // So, it was placed in repository just after an TV-instance creation but then
/**/ // it was removed (since we did not find it into the invoking method of this method look there at line with
/**/ // TypeVariableRepository.findTypeVariable(...) method invokation and also we did not find it in just above if-condition).
/**/ // As a consequence, we should reregistry it again as long as it become so popular again
/**/}
return va[i];
}
}
}
}
return null;
} else if (startPoint instanceof Method || startPoint instanceof Constructor) {
TypeVariable va[];
if (startPoint instanceof Method) {
va = ((Method)startPoint).getTypeParameters();
} else {
va = ((Constructor)startPoint).getTypeParameters();
}
if (va != null) {
for(int i = 0; i < va.length; i++){
if(va[i].getName().equals(transform(typeVariableName))){
/**/if (TypeVariableRepository.findTypeVariable(typeVariableName, startPoint) == null) { // Yes, it may be very inefficient now (for example, ((Constructor/Method)startPoint).getTypeParameters() invokation above can just registry a TV but we need to recheck it in this line) but
/**/ // after all the TV-repository's functionality implementation
/**/ // it will be time to improvement.
/**/ TypeVariableRepository.registerTypeVariable(va[i], typeVariableName, startPoint); // So, it was placed in repository just after an TV-instance creation but then
/**/ // it was removed (since we did not find it into the invoking method of this method look there at line with
/**/ // TypeVariableRepository.findTypeVariable(...) method invokation and also we did not find it in just above if-condition).
/**/ // As a consequence, we should reregistry it again as long as it become so popular again
/**/}
return va[i];
}
}
}
Class klass = (startPoint instanceof Method) ? ((Method)startPoint).getDeclaringClass() : ((Constructor)startPoint).getDeclaringClass();
if (startPoint instanceof Method) {
klass = ((Method)startPoint).getDeclaringClass();
} else {
klass = ((Constructor)startPoint).getDeclaringClass();
}
/**/java.lang.reflect.TypeVariable variable = TypeVariableRepository.findTypeVariable(typeVariableName, klass);
/**/if (variable != null) {
/**/ return variable;
/**/}
va = klass.getTypeParameters();
if (va != null) {
for(int i = 0; i < va.length; i++){
if(va[i].getName().equals(transform(typeVariableName))){
/**/if (TypeVariableRepository.findTypeVariable(typeVariableName, klass) == null) { // Yes, it may be very inefficient now (for example, klass.getTypeParameters() invokation above can just registry a TV but we need to recheck it in this line) but
/**/ // after all the TV-repository's functionality implementation
/**/ // it will be time to improvement.
/**/ TypeVariableRepository.registerTypeVariable(va[i], typeVariableName, klass); // So, it was placed in repository just after an TV-instance creation but then
/**/ // it was removed (since we did not find it into the invoking method of this method look there at line with
/**/ // TypeVariableRepository.findTypeVariable(...) method invokation and also we did not find it in just above if-condition).
/**/ // As a consequence, we should reregistry it again as long as it become so popular again
/**/}
return va[i];
}
}
}
while (klass != null) {
klass = klass.getDeclaringClass();
/**/variable = TypeVariableRepository.findTypeVariable(typeVariableName, klass);
/**/if (variable != null) {
/**/ return variable;
/**/}
va = klass.getTypeParameters();
if (va != null) {
for(int i = 0; i < va.length; i++){
if(va[i].getName().equals(transform(typeVariableName))){
/**/if (TypeVariableRepository.findTypeVariable(typeVariableName, klass) == null) { // Yes, it may be very inefficient now (for example, klass.getTypeParameters() invokation above can just registry a TV but we need to recheck it in this line) but
/**/ // after all the TV-repository's functionality implementation
/**/ // it will be time to improvement.
/**/ TypeVariableRepository.registerTypeVariable(va[i], typeVariableName, klass); // So, it was placed in repository just after an TV-instance creation but then
/**/ // it was removed (since we did not find it into the invoking method of this method look there at line with
/**/ // TypeVariableRepository.findTypeVariable(...) method invokation and also we did not find it in just above if-condition).
/**/ // As a consequence, we should reregistry it again as long as it become so popular again
/**/}
return va[i];
}
}
}
}
return null;
} else if (startPoint instanceof Class) {
Class klass = (Class)startPoint;
TypeVariable va[] = klass.getTypeParameters();
if (va != null) {
for(int i = 0; i < va.length; i++){
if(va[i].getName().equals(typeVariableName)){
/**/if (TypeVariableRepository.findTypeVariable(typeVariableName, klass) == null) { // Yes, it may be very inefficient now (for example, klass.getTypeParameters() invokation above can just registry a TV but we need to recheck it in this line) but
/**/ // after all the TV-repository's functionality implementation