public interface SourceBuilder
// Imports StringBuilder and appends " StringBuilder foo;\n" to the source code.
builder.addLine(" %s foo;", StringBuilder.class);| Modifier and Type | Method and Description |
|---|---|
SourceBuilder |
add(Excerpt excerpt)
Equivalent to
add("%s", excerpt). |
SourceBuilder |
add(String fmt,
Object... args)
Appends formatted text to the source.
|
SourceBuilder |
addLine(String fmt,
Object... args)
Appends a formatted line of code to the source.
|
SourceLevel |
getSourceLevel() |
boolean |
isGuavaAvailable() |
SourceStringBuilder |
subBuilder()
Returns a
SourceStringBuilder with the same configuration as this builder. |
SourceBuilder add(String fmt, Object... args)
Formatting is done by String.format(java.lang.String, java.lang.Object...), except that:
Package and PackageElement instances use their fully-qualified names
(no "package " prefix).
Class, TypeElement, DeclaredType and QualifiedName
instances use their qualified names where necessary, or shorter versions if a suitable
import line can be added.
Excerpt instances have Excerpt.addTo(SourceBuilder) called.
SourceBuilder addLine(String fmt, Object... args)
Formatting is done by String.format(java.lang.String, java.lang.Object...), except that:
Package and PackageElement instances use their fully-qualified names
(no "package " prefix).
Class, TypeElement, DeclaredType and QualifiedName
instances use their qualified names where necessary, or shorter versions if a suitable
import line can be added.
Excerpt instances have Excerpt.addTo(SourceBuilder) called.
SourceBuilder add(Excerpt excerpt)
add("%s", excerpt).SourceStringBuilder subBuilder()
SourceStringBuilder with the same configuration as this builder. In
particular, the TypeShortener will be shared, so any types added to the sub-builder
will be included in the imports for this builder (and its parents).SourceLevel getSourceLevel()
boolean isGuavaAvailable()
Copyright © 2016 Google, Inc.. All rights reserved.