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(java.lang.String fmt,
java.lang.Object... args)
Appends formatted text to the source.
|
SourceBuilder |
addLine(java.lang.String fmt,
java.lang.Object... args)
Appends a formatted line of code to the source.
|
<T extends Feature<T>> |
feature(FeatureType<T> featureType)
Returns the instance of
featureType appropriate for the source being written. |
SourceStringBuilder |
subBuilder()
Returns a
SourceStringBuilder with the same configuration as this builder. |
SourceBuilder add(java.lang.String fmt, java.lang.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).SourceBuilder addLine(java.lang.String fmt, java.lang.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.
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).<T extends Feature<T>> T feature(FeatureType<T> featureType)
featureType appropriate for the source being written. For
instance, code.feature(GUAVA).isAvailable() returns true if the Guava
library can be used in the generated source code.
Fluent extension point for features dynamically determined based on the current
ProcessingEnvironment.
Feature