javapoet-dsl / com.mostlycertain.javapoetdsl / expression

expression

fun expression(format: String, vararg args: Any): CodeExpression

Format java code as an expression.

The format markers are the sames as javapoet, except that this expects percent signs (%) as the format indicator, rather than dollar signs ($).

Parameters

format - code format string

args - format string arguments

See Also

e

fun expression(block: ExpressionBuilder.() -> Unit): CodeExpression

Build a java code expression.

Example of calling a builder:

expression { writeln("%T.builder()", BuilderClass);

indent { writeln(".foo(%L)", fooValue) writeln(".bar(%L)", barValue) write(".build()") } }

fun expression(vararg lines: CodeExpression): CodeExpression
fun expression(lines: List<CodeExpression>): CodeExpression

Build an expression where all the lines after the first are indented.

Example:

expression( e("%T.builder()", BuilderClass), e(".foo(%L)", fooValue), e(".bar(%L)", barValue), e(".build()"), )