Java Reference
In-Depth Information
System.out.println(" generic base class: ");
Type genericBase = c.getGenericSuperclass();
if(genericBase != null)
{
printType(genericBase, 4);
}
...
System.out.println(" declared methods:");
Method[] declaredMethods = c.getDeclaredMethods();
handleMethods(declaredMethods);
}
catch(ClassNotFoundException e)
{
System.out.println(className + ": not found");
}
}
private static void printType(Type t, int indentation)
{
printNTimes(' ', indentation);
if(t instanceof Class<?>)
{
Class<?> cls = (Class<?>) t;
if(cls.isInterface())
{
System.out.print("interface: ");
}
else
{
System.out.print("class: ");
}
System.out.println(cls.getName());
}
else if(t instanceof TypeVariable<?>)
{
TypeVariable<?> typeVar = (TypeVariable<?>) t;
System.out.println("type variable: " +
typeVar.getName());
printNTimes(' ', indentation+2);
System.out.println("bounds:");
Type[] bounds = typeVar.getBounds();
if(bounds.length == 1)
{
printType(bounds[0], indentation+4);
}
else
{
int i = 0;
for(Type bound : bounds)
{
i++;
printNTimes(' ', indentation+4);
System.out.println(i + ". bound:");
printType(bound, indentation+6);
}
 
Search WWH ::




Custom Search