public class Source
extends java.lang.Object
| Constructor and Description |
|---|
Source() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.lang.String> |
buildCollectedImportDecls(javax.lang.model.element.TypeElement t,
java.lang.Iterable<java.lang.String> extraImports)
Builds a `String` of import declarations collected from the given `TypeElement`; each of the
given `extraImports` will also be added as import declarations in the returned `String`.
|
static java.util.List<java.lang.String> |
buildCollectedImportDecls(javax.lang.model.element.TypeElement t,
java.lang.String... extraImports)
Builds a `String` of import declarations collected from the given `TypeElement`; each of the
given `extraImports` will also be added as import declarations in the returned `String`.
|
static java.lang.String |
buildExecutableDecl(javax.lang.model.element.ExecutableElement exec)
Builds a `String` matching the declaration of the executable element.
|
static java.util.List<java.lang.String> |
buildImportDecls(java.lang.Iterable<java.lang.String> imports)
Builds a
List<String> of import declarations from the given set of types. |
static java.lang.String |
buildModifiersList(javax.lang.model.element.ExecutableElement exec)
Builds a `String` matching the declared modifiers of the executable element.
|
static java.lang.String |
buildParameterNamesList(javax.lang.model.element.ExecutableElement exec)
Builds a `String` of the names of the formal parameters of the given executable, where each
name is separated by a comma.
|
static java.lang.String |
buildParametersList(javax.lang.model.element.ExecutableElement exec)
Builds a `String` matching the parameter list of the given executable element.
|
static java.lang.String |
buildVariableDecl(javax.lang.model.element.VariableElement var)
Builds a `String` matching the declaration of the given variable element.
|
static java.lang.String |
buildWithoutTypeArgs(javax.lang.model.type.DeclaredType t)
Builds a
String matching the type such that it is fully qualified and with any type
arguments dropped. |
static java.lang.String |
cat(int depth,
java.lang.String... lines)
Concatenates each of the lines, separating each with a single '\n' character and tabbing
each line over the specified `depth`.
|
static java.lang.String |
cat(java.lang.String... lines)
Concatenates each of the lines, separating each with a single '\n' character.
|
static java.lang.String |
dropPackageName(java.lang.String qualifiedClassName) |
static java.lang.String |
format(java.lang.String fmt,
java.lang.Object... items)
Inserts any elements in the given list of items into the format string at
format elements.
|
static java.lang.String |
formatAligned(java.lang.String fmt,
java.util.List<java.lang.String> items) |
static java.lang.String |
formatAligned(java.lang.String fmt,
java.lang.Object... lines)
Inserts each of the given `lines` into the `fmt` string at the first "##" such that each
line is inserted at the same depth as the "##".
|
static java.util.List<java.lang.String> |
formatAlignedFirst(java.util.List<java.lang.String> fmts,
java.util.List<java.lang.String> items) |
static java.util.List<java.lang.String> |
formatAlignedFirst(java.util.List<java.lang.String> fmts,
java.lang.Object... items)
Applies `formatAligned()` to the first format string in `fmts` which contains "##", and
includes each of the lines which have been expanded into the returned list.
|
static java.util.List<java.lang.String> |
formatAll(java.util.List<java.lang.String> fmts,
java.lang.Object... items)
Applies the appropriate `format()` to each of the strings of the list, and returns the
result as another list of strings.
|
static java.util.List<java.lang.String> |
lines(int depth,
java.lang.String... lines)
A helper method for turning a variable-length method call into a list of strings, where each
line has been tabbed to the given depth.
|
static java.util.List<java.lang.String> |
lines(java.lang.String... lines)
A helper method for turning a variable-length method call into a list of strings.
|
static java.lang.String |
tab(int depth,
java.lang.String line) |
public static java.lang.String tab(int depth,
java.lang.String line)
public static java.lang.String cat(java.lang.String... lines)
public static java.lang.String cat(int depth,
java.lang.String... lines)
public static java.util.List<java.lang.String> lines(java.lang.String... lines)
public static java.util.List<java.lang.String> lines(int depth,
java.lang.String... lines)
public static java.lang.String formatAligned(java.lang.String fmt,
java.lang.Object... lines)
formatAligned(" ##", "foo", "bar", "baz") => " foo\n bar\n baz"
Technically, the portion of the line which precedes the "##" will be copied as the prefix of each of the lines being inserted.
Note that if `lines` is empty, then this method will return a string just like `fmt`, except with the first "##" characters removed.
java.lang.IllegalArgumentException - If any character of prefix is not a whitespace character.public static java.lang.String formatAligned(java.lang.String fmt,
java.util.List<java.lang.String> items)
public static java.util.List<java.lang.String> formatAlignedFirst(java.util.List<java.lang.String> fmts,
java.lang.Object... items)
public static java.util.List<java.lang.String> formatAlignedFirst(java.util.List<java.lang.String> fmts,
java.util.List<java.lang.String> items)
public static java.lang.String format(java.lang.String fmt,
java.lang.Object... items)
fmt that satisfies
the pattern #\d+", that is, a hash-symbol followed by one or more
digits. The digits of a format element are interpreted to be the index
into items used to find which item to place at that location. For
example,
Source.format("#0? #1, #0...", "World", "Hello") => "World? Hello, World..."
public static java.util.List<java.lang.String> formatAll(java.util.List<java.lang.String> fmts,
java.lang.Object... items)
public static java.lang.String dropPackageName(java.lang.String qualifiedClassName)
public static java.lang.String buildExecutableDecl(javax.lang.model.element.ExecutableElement exec)
public static java.lang.String buildModifiersList(javax.lang.model.element.ExecutableElement exec)
public static java.lang.String buildParametersList(javax.lang.model.element.ExecutableElement exec)
public static java.lang.String buildVariableDecl(javax.lang.model.element.VariableElement var)
public static java.lang.String buildParameterNamesList(javax.lang.model.element.ExecutableElement exec)
public static java.lang.String buildWithoutTypeArgs(javax.lang.model.type.DeclaredType t)
String matching the type such that it is fully qualified and with any type
arguments dropped. For example, if the given `t` represents a declared type
HashSet<Integer>
then this method would return "java.util.HashSet".public static java.util.List<java.lang.String> buildImportDecls(java.lang.Iterable<java.lang.String> imports)
List<String> of import declarations from the given set of types.
Each of the given String objects is assumed to be a fully qualified type that can
be imported as-is. For example, if the following set of types were passed,
{ java.util.HashSet, java.util.Set, java.lang.String }
then this method would return the following imports declarations as a single `String`:
import java.util.HashSet;
import java.util.Set;
import java.lang.String;
public static java.util.List<java.lang.String> buildCollectedImportDecls(javax.lang.model.element.TypeElement t,
java.lang.String... extraImports)
public static java.util.List<java.lang.String> buildCollectedImportDecls(javax.lang.model.element.TypeElement t,
java.lang.Iterable<java.lang.String> extraImports)