public class Block extends Excerpt implements SourceBuilder
ValueType.FieldReceiver| Constructor and Description |
|---|
Block(SourceBuilder parent) |
| Modifier and Type | Method and Description |
|---|---|
Block |
add(Excerpt excerpt)
Equivalent to
add("%s", excerpt). |
Block |
add(java.lang.String fmt,
java.lang.Object... args)
Appends formatted text to the source.
|
protected void |
addFields(ValueType.FieldReceiver fields)
Implement this method to report the name and value of each field.
|
Block |
addLine(java.lang.String fmt,
java.lang.Object... args)
Appends a formatted line of code to the source.
|
void |
addTo(SourceBuilder source) |
Excerpt |
declare(java.lang.String name,
java.lang.String declfmt,
java.lang.Object... declArgs)
Declare
name in this block's preamble, returning an Excerpt to use it. |
<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. |
public Block(SourceBuilder parent)
public Excerpt declare(java.lang.String name, java.lang.String declfmt, java.lang.Object... declArgs)
name in this block's preamble, returning an Excerpt to use it. Duplicate
declarations will be elided.java.lang.IllegalStateException - if name has already been added to this block with a
different declarationpublic Block add(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.
add in interface SourceBuilderpublic Block 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 Block add(Excerpt excerpt)
SourceBuilderadd("%s", excerpt).add 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 <T extends Feature<T>> T feature(FeatureType<T> featureType)
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 void addTo(SourceBuilder source)
protected void addFields(ValueType.FieldReceiver fields)
ValueType