public final class SourceStringBuilder extends Object implements SourceBuilder
SourceBuilder that writes to a StringBuilder.| 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() |
static SourceBuilder |
simple(SourceLevel sourceLevel,
boolean isGuavaAvailable)
Returns a
SourceStringBuilder that always shortens types, even if that causes
conflicts. |
SourceStringBuilder |
subBuilder()
Returns a
SourceStringBuilder with the same configuration as this builder. |
String |
toString()
Returns the source code written so far.
|
public static SourceBuilder simple(SourceLevel sourceLevel, boolean isGuavaAvailable)
SourceStringBuilder that always shortens types, even if that causes
conflicts.public SourceBuilder add(Excerpt excerpt)
SourceBuilderadd("%s", excerpt).add in interface SourceBuilderpublic SourceBuilder add(String fmt, 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 SourceBuilder addLine(String fmt, 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 SourceLevel getSourceLevel()
getSourceLevel in interface SourceBuilderpublic boolean isGuavaAvailable()
isGuavaAvailable in interface SourceBuilderCopyright © 2016 Google, Inc.. All rights reserved.