/** * Returns the parsed type signature for the method, possibly including type parameters. If the parsed type * signature is null, indicating that no type signature information is available for this method, returns the * parsed type descriptor instead. * * @return The parsed type signature for the method, or if not available, the parsed type descriptor for the * method. */ public MethodTypeSignature getTypeSignatureOrTypeDescriptor() { final MethodTypeSignature typeSig = getTypeSignature(); if (typeSig != null) { return typeSig; } else { return getTypeDescriptor(); } }
/** * Returns the result type signature for the method (with type parameters, if present). If this is a * constructor, the returned type will be void. * * @return The type signature of the result of this method, or null if type signature information is not * available. */ public TypeSignature getResultTypeSignature() { final MethodTypeSignature ts = getTypeSignature(); if (ts == null) { return null; } else { return ts.getResultType(); } }
/** * Get the names of any classes referenced in the type descriptors of this class' methods (if method info is * recorded). * * @return The names of the referenced classes. */ public Set<String> getClassNamesReferencedInMethodTypeDescriptors() { final Set<String> referencedClassNames = new HashSet<>(); if (methodInfo != null) { for (final MethodInfo mi : methodInfo) { final MethodTypeSignature methodSig = mi.getTypeSignature(); if (methodSig != null) { methodSig.getAllReferencedClassNames(referencedClassNames); } } } // Remove any reference to java.lang.Object referencedClassNames.remove("java.lang.Object"); return referencedClassNames; }
/** * Returns the type parameters of the method, in string representation, e.g. {@code ["<X>", * "<Y>"]}. * * @return The type parameters of the method, in string representation, e.g. {@code ["<X>", * "<Y>"]}. If the method has no type parameters, returns a zero-sized array. */ public String[] getTypeParameterStrs() { return toStringArray(getTypeSignature().getTypeParameters()); }
/** * Returns the types of exceptions the method may throw, in string representation, e.g. {@code * ["com.abc.BadException", "<X>"]}. * * @return The types of exceptions the method may throw. If the method throws no exceptions, returns a * zero-sized array. */ public ClassRefOrTypeVariableSignature[] getThrowsTypeSignatures() { return toTypeOrTypeVariableSignatureArray(getTypeSignature().getThrowsSignatures()); }
/** * Returns the type parameters of the method. * * @return The type parameters of the method. If the method has no type parameters, returns a zero-sized array. */ public TypeParameter[] getTypeParameters() { return toTypeParameterArray(getTypeSignature().getTypeParameters()); }
/** * Returns the types of exceptions the method may throw. * * @return The types of exceptions the method may throw. If the method throws no exceptions, returns a * zero-sized array. */ public Class<?>[] getThrowsTypes() { return toClassRefs(getTypeSignature().getThrowsSignatures(), scanResult); }
/** * Returns the types of exceptions the method may throw, in string representation, e.g. {@code * ["com.abc.BadException", "<X>"]}. * * @return The types of exceptions the method may throw, as Strings. If the method throws no exceptions, returns * a zero-sized array. */ public String[] getThrowsTypeStrs() { return toStringArray(getTypeSignature().getThrowsSignatures()); }
final List<TypeSignature> paramTypeSignatures = getTypeSignature() != null ? getTypeSignature().getParameterTypeSignatures() : null;
public void println(MethodInfo method, String indentation) { append(asAnnotations(method.getAnnotationNames(), indentation)); append(indentation); if (method.getModifiersStr() != null) { append(method.getModifiersStr()).append(' '); } if (!method.isConstructor()) { append(removeQualifierFromBaseTypes(method.getResultTypeStr())).append(' '); } append(method.getMethodName()).append('('); LinkedList<String> paramTypes = method .getTypeSignature() .getParameterTypeSignatures() .stream() .map(ApiPrintWriter::removeQualifierFromBaseTypes) .collect(toCollection(LinkedList::new)); //if parameter is varargs, remove the array [] qualifier and replace with ellipsis if (method.isVarArgs() && !paramTypes.isEmpty()) { String vararg = paramTypes.removeLast(); paramTypes.add(vararg.substring(0, vararg.length() - 2) + "..."); } append(paramTypes.stream().collect(joining(", "))); println(')'); }
if (methodInfo != null) { for (final MethodInfo mi : methodInfo) { final MethodTypeSignature methodSig = mi.getTypeSignature(); if (methodSig != null) { methodSig.getAllReferencedClassNames(referencedClassNames);