List of usage examples for java.lang.reflect WildcardType toString
public String toString()
From source file:net.radai.beanz.util.ReflectionUtil.java
public static String prettyPrint(Type type) { if (type instanceof GenericArrayType) { GenericArrayType genericArrayType = (GenericArrayType) type; return prettyPrint(genericArrayType.getGenericComponentType()) + "[]"; }/*from w w w . j a v a 2 s . c om*/ if (type instanceof WildcardType) { WildcardType wildcardType = (WildcardType) type; return wildcardType.toString(); } if (type instanceof TypeVariable) { TypeVariable<?> typeVariable = (TypeVariable) type; return typeVariable.getName(); } if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; StringBuilder sb = new StringBuilder(); sb.append(prettyPrint(parameterizedType.getRawType())); Type[] typeArguments = parameterizedType.getActualTypeArguments(); if (typeArguments != null && typeArguments.length > 0) { sb.append("<"); for (Type typeArgument : typeArguments) { sb.append(prettyPrint(typeArgument)).append(", "); } sb.delete(sb.length() - 2, sb.length()); // last ", " sb.append(">"); } return sb.toString(); } Class<?> clazz = (Class<?>) type; if (clazz.isArray()) { return prettyPrint(clazz.getComponentType()) + "[]"; } return clazz.getSimpleName(); }