Class CodeBlock
java.lang.Object
com.squareup.javapoet.CodeBlock
A fragment of a .java file, potentially containing declarations, statements, and documentation.
Code blocks are not necessarily well-formed Java code, and are not validated. This class assumes
javac will check correctness later!
Code blocks support placeholders like Format. Where String.format(String, Object...)
uses percent % to reference target values, this class uses dollar sign $ and has
its own set of permitted placeholders:
$Lemits a literal value with no escaping. Arguments for literals may be strings, primitives, type declarations, annotations and even other code blocks.$Nemits a name, using name collision avoidance where necessary. Arguments for names may be strings (actually any character sequence), parameters, fields, methods, and types.$Sescapes the value as a string, wraps it with double quotes, and emits that. For example,6" sandwichis emitted"6\" sandwich".$Temits a type reference. Types will be imported if possible. Arguments for types may be classes, ,* type mirrors, and elements.$$emits a dollar sign.$>increases the indentation level.$<decreases the indentation level.$[begins a statement. For multiline statements, every line after the first line is double-indented.$]ends a statement.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
formatParts
-
args
-
-
Constructor Details
-
CodeBlock
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
equals
-
hashCode
-
toString
-
of
-
builder
-
toBuilder
-