JavaFile to a string suitable to both human- and javac-consumption. This
honors imports, indentation, and deferred variable names.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final Set | |
| private boolean | |
| private final CodeWriter. | |
| private final Map | |
| private final Map | |
| private final String | |
| private int | |
| private boolean | |
| private static final String | NO_PACKAGE
Sentinel value that indicates that no user-provided package has been set. |
| private final LineWrapper | |
| private String | |
| private final Set | |
| pack-priv int | statementLine
When emitting a statement, this is the line of the statement currently being written. |
| private final Set | |
| private final Set | |
| private boolean | |
| private final List |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | |
| pack-priv | CodeWriter(Appendable out, String indent, Map<String, ClassName> importedTypes, Set<String> staticImports, Set<String> alwaysQualify)
|
| Modifier and Type | Method and Description |
|---|---|
| public CodeWriter | |
| public CodeWriter | |
| public CodeWriter | |
| public CodeWriter | |
| pack-priv CodeWriter | |
| public void | |
| public void | |
| private void | |
| public void | |
| private void | |
| public void | emitModifiers(Set<Modifier> modifiers, Set<Modifier> implicitModifiers)
Emits |
| public void | |
| private boolean | |
| public void | |
| public CodeWriter | |
| private static String | |
| private void | |
| public Map | |
| public CodeWriter | |
| public CodeWriter | |
| pack-priv String | lookupName(ClassName className)
Returns the best name to identify |
| public CodeWriter | |
| public CodeWriter | |
| public void | |
| public CodeWriter | |
| public CodeWriter | |
| private ClassName | |
| private ClassName | stackClassName(int stackDepth, String simpleName)
Returns the class named |
| pack-priv Map | |
| public CodeWriter | |
| public CodeWriter |
| alwaysQualify | back to summary |
|---|---|
| private final Set<String> alwaysQualify | |
| comment | back to summary |
|---|---|
| private boolean comment | |
| currentTypeVariables | back to summary |
|---|---|
| private final CodeWriter. | |
| importableTypes | back to summary |
|---|---|
| private final Map<String, ClassName> importableTypes | |
| importedTypes | back to summary |
|---|---|
| private final Map<String, ClassName> importedTypes | |
| indent | back to summary |
|---|---|
| private final String indent | |
| indentLevel | back to summary |
|---|---|
| private int indentLevel | |
| javadoc | back to summary |
|---|---|
| private boolean javadoc | |
| NO_PACKAGE | back to summary |
|---|---|
| private static final String NO_PACKAGE Sentinel value that indicates that no user-provided package has been set. | |
| out | back to summary |
|---|---|
| private final LineWrapper out | |
| packageName | back to summary |
|---|---|
| private String packageName | |
| referencedNames | back to summary |
|---|---|
| private final Set<String> referencedNames | |
| statementLine | back to summary |
|---|---|
| pack-priv int statementLine When emitting a statement, this is the line of the statement currently being written. The first line of a statement is indented normally and subsequent wrapped lines are double-indented. This is -1 when the currently-written line isn't part of a statement. | |
| staticImportClassNames | back to summary |
|---|---|
| private final Set<String> staticImportClassNames | |
| staticImports | back to summary |
|---|---|
| private final Set<String> staticImports | |
| trailingNewline | back to summary |
|---|---|
| private boolean trailingNewline | |
| typeSpecStack | back to summary |
|---|---|
| private final List<TypeSpec> typeSpecStack | |
| CodeWriter | back to summary |
|---|---|
| pack-priv CodeWriter(Appendable out) | |
| CodeWriter | back to summary |
|---|---|
| pack-priv CodeWriter(Appendable out, String indent, Set<String> staticImports, Set<String> alwaysQualify) | |
| CodeWriter | back to summary |
|---|---|
| pack-priv CodeWriter(Appendable out, String indent, Map<String, ClassName> importedTypes, Set<String> staticImports, Set<String> alwaysQualify) | |
| emit | back to summary |
|---|---|
| public CodeWriter emit(String s) throws IOException | |
| emit | back to summary |
|---|---|
| public CodeWriter emit(String format, Object... args) throws IOException | |
| emit | back to summary |
|---|---|
| public CodeWriter emit(CodeBlock codeBlock) throws IOException | |
| emit | back to summary |
|---|---|
| public CodeWriter emit(CodeBlock codeBlock, boolean ensureTrailingNewline) throws IOException | |
| emitAndIndent | back to summary |
|---|---|
| pack-priv CodeWriter emitAndIndent(String s) throws IOException Emits | |
| emitAnnotations | back to summary |
|---|---|
| public void emitAnnotations(List<AnnotationSpec> annotations, boolean inline) throws IOException | |
| emitComment | back to summary |
|---|---|
| public void emitComment(CodeBlock codeBlock) throws IOException | |
| emitIndentation | back to summary |
|---|---|
| private void emitIndentation() throws IOException | |
| emitJavadoc | back to summary |
|---|---|
| public void emitJavadoc(CodeBlock javadocCodeBlock) throws IOException | |
| emitLiteral | back to summary |
|---|---|
| private void emitLiteral(Object o) throws IOException | |
| emitModifiers | back to summary |
|---|---|
| public void emitModifiers(Set<Modifier> modifiers, Set<Modifier> implicitModifiers) throws IOException Emits | |
| emitModifiers | back to summary |
|---|---|
| public void emitModifiers(Set<Modifier> modifiers) throws IOException | |
| emitStaticImportMember | back to summary |
|---|---|
| private boolean emitStaticImportMember(String canonical, String part) throws IOException | |
| emitTypeVariables | back to summary |
|---|---|
| public void emitTypeVariables(List<TypeVariableName> typeVariables) throws IOException Emit type variables with their bounds. This should only be used when declaring type variables; everywhere else bounds are omitted. | |
| emitWrappingSpace | back to summary |
|---|---|
| public CodeWriter emitWrappingSpace() throws IOException | |
| extractMemberName | back to summary |
|---|---|
| private static String extractMemberName(String part) | |
| importableType | back to summary |
|---|---|
| private void importableType(ClassName className) | |
| importedTypes | back to summary |
|---|---|
| public Map | |
| indent | back to summary |
|---|---|
| public CodeWriter indent() | |
| indent | back to summary |
|---|---|
| public CodeWriter indent(int levels) | |
| lookupName | back to summary |
|---|---|
| pack-priv String lookupName(ClassName className) Returns the best name to identify | |
| popPackage | back to summary |
|---|---|
| public CodeWriter popPackage() | |
| popType | back to summary |
|---|---|
| public CodeWriter popType() | |
| popTypeVariables | back to summary |
|---|---|
| public void popTypeVariables(List<TypeVariableName> typeVariables) throws IOException | |
| pushPackage | back to summary |
|---|---|
| public CodeWriter pushPackage(String packageName) | |
| pushType | back to summary |
|---|---|
| public CodeWriter pushType(TypeSpec type) | |
| resolve | back to summary |
|---|---|
| private ClassName resolve(String simpleName) Returns the class referenced by | |
| stackClassName | back to summary |
|---|---|
| private ClassName stackClassName(int stackDepth, String simpleName) Returns the class named | |
| suggestedImports | back to summary |
|---|---|
| pack-priv Map Returns the types that should have been imported for this code. If there were any simple name collisions, that type's first use is imported. | |
| unindent | back to summary |
|---|---|
| public CodeWriter unindent() | |
| unindent | back to summary |
|---|---|
| public CodeWriter unindent(int levels) | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv boolean | |
| pack-priv void |
| map | back to summary |
|---|---|
| private final Map<T, Integer> map | |
| Multiset | back to summary |
|---|---|
| private Multiset() | |
| add | back to summary |
|---|---|
| pack-priv void add(T t) | |
| contains | back to summary |
|---|---|
| pack-priv boolean contains(T t) | |
| remove | back to summary |
|---|---|
| pack-priv void remove(T t) | |