/** * Appends names of the {@code types} to {@code out} separated by commas. */ public static void appendArrayGenericType(StringBuilder out, Type[] types) { if (types.length == 0) { return; } appendGenericType(out, types[0]); for (int i = 1; i < types.length; i++) { out.append(','); appendGenericType(out, types[i]); } }
/** * Returns the names of {@code types} separated by commas. */ public static String toString(Class<?>[] types) { if (types.length == 0) { return ""; } StringBuilder result = new StringBuilder(); appendTypeName(result, types[0]); for (int i = 1; i < types.length; i++) { result.append(','); appendTypeName(result, types[i]); } return result.toString(); }
/** * Returns the internal name of {@code clazz} (also known as the descriptor). */ public static String getSignature(Class<?> clazz) { String primitiveSignature = PRIMITIVE_TO_SIGNATURE.get(clazz); if (primitiveSignature != null) { return primitiveSignature; } else if (clazz.isArray()) { return "[" + getSignature(clazz.getComponentType()); } else { // TODO: this separates packages with '.' rather than '/' return "L" + clazz.getName() + ";"; } }
appendGenericType(sb, Types.getType(genericReturnType)); sb.append(' '); appendArrayGenericType(sb, Types.getTypeArray(genericParameterTypes, false)); sb.append(')'); Type[] genericExceptionTypeArray = Types.getTypeArray(genericExceptionTypes, false); if (genericExceptionTypeArray.length > 0) { sb.append(" throws ");
/** * Returns the exception types as an array of {@code Type} instances. If * this method has no declared exceptions, an empty array will be returned. * * @return an array of generic exception types * * @throws GenericSignatureFormatError * if the generic method signature is invalid * @throws TypeNotPresentException * if any exception type points to a missing type * @throws MalformedParameterizedTypeException * if any exception type points to a type that cannot be * instantiated for some reason */ public Type[] getGenericExceptionTypes() { initGenericTypes(); return Types.getTypeArray(genericExceptionTypes, true); }
/** * Returns the generic type of this field. * * @return the generic type * @throws GenericSignatureFormatError * if the generic field signature is invalid * @throws TypeNotPresentException * if the generic type points to a missing type * @throws MalformedParameterizedTypeException * if the generic type points to a type that cannot be * instantiated for some reason */ public Type getGenericType() { initGenericType(); return Types.getType(genericType); }
/** * Returns the parameter types as an array of {@code Type} instances, in * declaration order. If this method has no parameters, an empty array is * returned. * * @return the parameter types * * @throws GenericSignatureFormatError * if the generic method signature is invalid * @throws TypeNotPresentException * if any parameter type points to a missing type * @throws MalformedParameterizedTypeException * if any parameter type points to a type that cannot be * instantiated for some reason */ public Type[] getGenericParameterTypes() { initGenericTypes(); return Types.getTypeArray(genericParameterTypes, true); }
appendGenericType(sb, Types.getType(genericReturnType)); sb.append(' '); appendArrayGenericType(sb, Types.getTypeArray(genericParameterTypes, false)); sb.append(')'); Type[] genericExceptionTypeArray = Types.getTypeArray(genericExceptionTypes, false); if (genericExceptionTypeArray.length > 0) { sb.append(" throws ");
/** * Returns the return type of this method as a {@code Type} instance. * * @return the return type of this method * * @throws GenericSignatureFormatError * if the generic method signature is invalid * @throws TypeNotPresentException * if the return type points to a missing type * @throws MalformedParameterizedTypeException * if the return type points to a type that cannot be * instantiated for some reason */ public Type getGenericReturnType() { initGenericTypes(); return Types.getType(genericReturnType); }
/** * Returns the generic parameter types as an array of {@code Type} * instances, in declaration order. If this constructor has no generic * parameters, an empty array is returned. * * @return the parameter types * * @throws GenericSignatureFormatError * if the generic constructor signature is invalid * @throws TypeNotPresentException * if any parameter type points to a missing type * @throws MalformedParameterizedTypeException * if any parameter type points to a type that cannot be * instantiated for some reason */ public Type[] getGenericParameterTypes() { initGenericTypes(); return Types.getTypeArray(genericParameterTypes, true); }
appendGenericType(sb, Types.getType(genericReturnType)); sb.append(' '); appendArrayGenericType(sb, Types.getTypeArray(genericParameterTypes, false)); sb.append(')'); Type[] genericExceptionTypeArray = Types.getTypeArray(genericExceptionTypes, false); if (genericExceptionTypeArray.length > 0) { sb.append(" throws ");
/** * Returns the {@code Type} that represents the superclass of this {@code * class}. */ public Type getGenericSuperclass() { GenericSignatureParser parser = new GenericSignatureParser(getClassLoader()); parser.parseForClass(this, getSignatureAttribute()); return Types.getType(parser.superclassType); }
} else if (type instanceof GenericArrayType) { Type simplified = ((GenericArrayType) type).getGenericComponentType(); appendGenericType(out, simplified); out.append("[]"); } else if (type instanceof Class) {
/** * Returns the internal name of {@code clazz} (also known as the descriptor). */ public static String getSignature(Class<?> clazz) { String primitiveSignature = PRIMITIVE_TO_SIGNATURE.get(clazz); if (primitiveSignature != null) { return primitiveSignature; } else if (clazz.isArray()) { return "[" + getSignature(clazz.getComponentType()); } else { // TODO: this separates packages with '.' rather than '/' return "L" + clazz.getName() + ";"; } }
/** * Returns the names of {@code types} separated by commas. */ public static String toString(Class<?>[] types) { if (types.length == 0) { return ""; } StringBuilder result = new StringBuilder(); appendTypeName(result, types[0]); for (int i = 1; i < types.length; i++) { result.append(','); appendTypeName(result, types[i]); } return result.toString(); }
/** * Returns the exception types as an array of {@code Type} instances. If * this constructor has no declared exceptions, an empty array will be * returned. * * @return an array of generic exception types * * @throws GenericSignatureFormatError * if the generic constructor signature is invalid * @throws TypeNotPresentException * if any exception type points to a missing type * @throws MalformedParameterizedTypeException * if any exception type points to a type that cannot be * instantiated for some reason */ public Type[] getGenericExceptionTypes() { initGenericTypes(); return Types.getTypeArray(genericExceptionTypes, true); }
appendGenericType(sb, Types.getType(genericReturnType)); sb.append(' '); appendArrayGenericType(sb, Types.getTypeArray(genericParameterTypes, false)); sb.append(')'); Type[] genericExceptionTypeArray = Types.getTypeArray(genericExceptionTypes, false); if (genericExceptionTypeArray.length > 0) { sb.append(" throws ");
/** * Returns the generic type of this field. * * @return the generic type * @throws GenericSignatureFormatError * if the generic field signature is invalid * @throws TypeNotPresentException * if the generic type points to a missing type * @throws MalformedParameterizedTypeException * if the generic type points to a type that cannot be * instantiated for some reason */ public Type getGenericType() { initGenericType(); return Types.getType(genericType); }
/** * Appends names of the {@code types} to {@code out} separated by commas. */ public static void appendArrayGenericType(StringBuilder out, Type[] types) { if (types.length == 0) { return; } appendGenericType(out, types[0]); for (int i = 1; i < types.length; i++) { out.append(','); appendGenericType(out, types[i]); } }
/** * Returns the internal name of {@code clazz} (also known as the descriptor). */ public static String getSignature(Class<?> clazz) { String primitiveSignature = PRIMITIVE_TO_SIGNATURE.get(clazz); if (primitiveSignature != null) { return primitiveSignature; } else if (clazz.isArray()) { return "[" + getSignature(clazz.getComponentType()); } else { // TODO: this separates packages with '.' rather than '/' return "L" + clazz.getName() + ";"; } }