diff options
Diffstat (limited to 'src/main/java/com/squareup/javapoet/TypeVariableName.java')
-rw-r--r-- | src/main/java/com/squareup/javapoet/TypeVariableName.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/com/squareup/javapoet/TypeVariableName.java b/src/main/java/com/squareup/javapoet/TypeVariableName.java index ac861f3..b4e1ac0 100644 --- a/src/main/java/com/squareup/javapoet/TypeVariableName.java +++ b/src/main/java/com/squareup/javapoet/TypeVariableName.java @@ -35,6 +35,11 @@ public final class TypeVariableName extends TypeName { public final List<TypeName> bounds; private TypeVariableName(String name, List<TypeName> bounds) { + this(name, bounds, new ArrayList<AnnotationSpec>()); + } + + private TypeVariableName(String name, List<TypeName> bounds, List<AnnotationSpec> annotations) { + super(annotations); this.name = checkNotNull(name, "name == null"); this.bounds = bounds; @@ -43,6 +48,14 @@ public final class TypeVariableName extends TypeName { } } + @Override public TypeVariableName annotated(AnnotationSpec... annotations) { + return annotated(Arrays.asList(annotations)); + } + + @Override public TypeVariableName annotated(List<AnnotationSpec> annotations) { + return new TypeVariableName(name, bounds, annotations); + } + private static TypeVariableName of(String name, List<TypeName> bounds) { // Strip java.lang.Object from bounds if it is present. List<TypeName> boundsNoObject = new ArrayList<>(bounds); @@ -61,7 +74,7 @@ public final class TypeVariableName extends TypeName { } @Override CodeWriter emit(CodeWriter out) throws IOException { - return out.emitAndIndent(name); + return emitAnnotations(out).emitAndIndent(name); } /** Returns type variable named {@code name} without bounds. */ |