/** * Append type parameters * * @param buf Buffer to append to * @param typeParameters Type parameters * @param annotatedSignatureWriter Signature writer * @return <code>true</code> if any nullability information was written * @throws IOException if we fail completely... */ protected boolean appendTypeParameters(StringBuilder buf, TypeList.Generic typeParameters, MethodSignatureWriter annotatedSignatureWriter) throws IOException { String plainTypeVariables = this.signatureWriter.appendTypeParameters(typeParameters, new StringBuilder()) .toString(); String annotatedTypeVariables = annotatedSignatureWriter .appendTypeParameters(typeParameters, new StringBuilder()).toString(); buf.append(plainTypeVariables).append("\n"); buf.append(annotatedTypeVariables).append("\n"); boolean annotated = !plainTypeVariables.equals(annotatedTypeVariables); return annotated; }
/** * Append type parameters * * @param buf Buffer to append to * @param typeParameters Type parameters * @param annotatedSignatureWriter Signature writer * @return <code>true</code> if any nullability information was written * @throws IOException if we fail completely... */ protected boolean appendTypeParameters(StringBuilder buf, TypeList.Generic typeParameters, MethodSignatureWriter annotatedSignatureWriter) throws IOException { String plainTypeVariables = this.signatureWriter.appendTypeParameters(typeParameters, new StringBuilder()) .toString(); String annotatedTypeVariables = annotatedSignatureWriter .appendTypeParameters(typeParameters, new StringBuilder()).toString(); buf.append(plainTypeVariables).append("\n"); buf.append(annotatedTypeVariables).append("\n"); boolean annotated = !plainTypeVariables.equals(annotatedTypeVariables); return annotated; }
/** * Append a method signature * * @param method Method to append signature of * @param output Output to append to * @param <A> Type of output * @return Supplied output to append to */ public <A extends Appendable> A appendMethodSignature(MethodDescription method, A output) { try { if (!method.getTypeVariables().isEmpty()) { appendTypeParameters(method.getTypeVariables(), output); } output.append('('); for (ParameterDescription parameter : method.getParameters()) { Nullness nullable = this.nullability.getParameterNullability(parameter); appendJavaTypeSignature(parameter.getType(), nullable, output); } output.append(')'); Nullness nullable = this.nullability.getReturnValueNullability(method); appendJavaTypeSignature(method.getReturnType(), nullable, output); return output; } catch (Exception e) { throw new RuntimeException(String.format("Could not write method signature %s", method)); } }
/** * Append a method signature * * @param method Method to append signature of * @param output Output to append to * @param <A> Type of output * @return Supplied output to append to */ public <A extends Appendable> A appendMethodSignature(MethodDescription method, A output) { try { if (!method.getTypeVariables().isEmpty()) { appendTypeParameters(method.getTypeVariables(), output); } output.append('('); for (ParameterDescription parameter : method.getParameters()) { Nullness nullable = this.nullability.getParameterNullability(parameter); appendJavaTypeSignature(parameter.getType(), nullable, output); } output.append(')'); Nullness nullable = this.nullability.getReturnValueNullability(method); appendJavaTypeSignature(method.getReturnType(), nullable, output); return output; } catch (Exception e) { throw new RuntimeException(String.format("Could not write method signature %s", method)); } }