public abstract class AbstractSourceBuilder<B extends AbstractSourceBuilder<B>> extends java.lang.Object implements SourceBuilder, java.lang.Appendable
| Modifier and Type | Field and Description |
|---|---|
protected FeatureSet |
features |
protected Scope |
scope |
protected org.inferred.freebuilder.processor.util.TypeMirrorShortener |
typeMirrorShortener |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSourceBuilder(FeatureSet features,
Scope scope) |
| Modifier and Type | Method and Description |
|---|---|
B |
add(Excerpt excerpt)
Equivalent to
add("%s", excerpt). |
B |
add(java.lang.String template,
java.lang.Object... params)
Appends formatted text to the source.
|
B |
addLine(java.lang.String fmt,
java.lang.Object... args)
Appends a formatted line of code to the source.
|
abstract java.lang.Appendable |
append(char c) |
java.lang.Appendable |
append(java.lang.CharSequence csq) |
java.lang.Appendable |
append(java.lang.CharSequence csq,
int start,
int end) |
<T extends Feature<T>> |
feature(FeatureType<T> feature)
Returns the instance of
featureType appropriate for the source being written. |
protected abstract org.inferred.freebuilder.processor.util.TypeShortener |
getShortener() |
protected abstract B |
getThis() |
Scope |
scope()
Returns the current scope (e.g.
|
SourceStringBuilder |
subBuilder()
Returns a
SourceStringBuilder with the same configuration as this builder. |
SourceStringBuilder |
subScope(Scope newScope)
Returns a
SourceStringBuilder with the same configuration as this builder, but with
a different scope. |
protected final FeatureSet features
protected final Scope scope
protected final org.inferred.freebuilder.processor.util.TypeMirrorShortener typeMirrorShortener
protected AbstractSourceBuilder(FeatureSet features, Scope scope)
protected abstract org.inferred.freebuilder.processor.util.TypeShortener getShortener()
protected abstract B getThis()
public abstract java.lang.Appendable append(char c)
append in interface java.lang.Appendablepublic B add(Excerpt excerpt)
SourceBuilderadd("%s", excerpt).add in interface SourceBuilderpublic B add(java.lang.String template, java.lang.Object... params)
SourceBuilderFormatting 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.
add in interface SourceBuilderpublic B addLine(java.lang.String fmt, java.lang.Object... args)
SourceBuilderFormatting 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.
addLine in interface SourceBuilderpublic SourceStringBuilder subBuilder()
SourceBuilderSourceStringBuilder 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).subBuilder in interface SourceBuilderpublic SourceStringBuilder subScope(Scope newScope)
SourceBuilderSourceStringBuilder with the same configuration as this builder, but with
a different scope. 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).subScope in interface SourceBuilderpublic <T extends Feature<T>> T feature(FeatureType<T> feature)
SourceBuilderfeatureType 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 in interface SourceBuilderFeaturepublic Scope scope()
SourceBuilderscope in interface SourceBuilderpublic java.lang.Appendable append(java.lang.CharSequence csq)
append in interface java.lang.Appendablepublic java.lang.Appendable append(java.lang.CharSequence csq,
int start,
int end)
append in interface java.lang.Appendable