kotlinpoet / com.squareup.kotlinpoet / CodeBlock

CodeBlock

class CodeBlock

A fragment of a .kt file, potentially containing declarations, statements, and documentation. Code blocks are not necessarily well-formed Kotlin code, and are not validated. This class assumes kotlinc will check correctness later!

Code blocks support placeholders like java.text.Format. This class primarily uses a percent sign % but has its own set of permitted placeholders:

Types

Builder

class Builder

Functions

equals

fun equals(other: Any?): Boolean

hashCode

fun hashCode(): Int

isEmpty

fun isEmpty(): Boolean

A heterogeneous list containing string literals and value placeholders.

isNotEmpty

fun isNotEmpty(): Boolean

toBuilder

fun toBuilder(): CodeBlock.Builder

toString

fun toString(): String

Companion Object Functions

builder

fun builder(): CodeBlock.Builder

of

fun of(format: String, vararg args: Any?): CodeBlock