WhenTrue

annotation class WhenTrue(val expression: String)

Conditional field: only present on the wire when the referenced expression is true. The field must be nullable with a default value of null.

@ProtocolMessage
data class OptionalPayload(
val hasExtra: Boolean,
@WhenTrue("hasExtra") val extra: Int? = null, // only read/written when hasExtra == true
)

Dotted expressions access properties on value class fields:

@WhenTrue("flags.willFlag") val willTopic: String? = null

Parameters

expression

"fieldName" for a Boolean field, or "fieldName.property" for a property on a value class field.

Properties

Link copied to clipboard