- final StringBuilder sb = new StringBuilder();
- sb.append(getReferenceString(type.getIdentifier())).append('<');
- final Type[] types = ((ParameterizedType) type).getActualTypeArguments();
- if (types.length == 0) {
- return sb.append("?>").toString();
+ final String getReferenceString(final Type type, final String annotation) {
+ // Package-private method, all callers who would be passing an empty array are bound to the more special
+ // case above, hence we know annotations.length >= 1
+ final String ref = getReferenceString(type.getIdentifier());
+ return type instanceof ParameterizedType ? getReferenceString(annotate(ref, annotation), type,
+ ((ParameterizedType) type).getActualTypeArguments())
+ : annotate(ref, annotation).toString();
+ }
+
+ private String getReferenceString(final StringBuilder sb, final Type type, final @NonNull Type[] arguments) {
+ if (arguments.length == 0) {
+ return sb.append("<?>").toString();