class ContextMessage<V> : Any

A class for adding context messages to an object of type V.

Fields

Name Description
val messages: messages.filter { it.isNotBlank() }
val value: V

actual object to be enriched by messages

Constructors

<init>

constructor(value: V, message: String)

Parameters

Name Description
value: V
message: String

<init>

constructor(value: V, messages: List<String>)

A class for adding context messages to an object of type V.

Parameters

Name Description
value: V

actual object to be enriched by messages

messages: List<String>

the actual list of messages to be added to the object

Methods

isEmpty

fun isEmpty(): messages.isEmpty()

ReturnValue

Name Description
messages.isEmpty()

isNotEmpty

fun isNotEmpty(): messages.isNotEmpty()

ReturnValue

Name Description
messages.isNotEmpty()

appendMessages

fun appendMessages(messages: List<String>): ContextMessage(this.value, this.messages + messages)

Parameters

Name Description
messages: List<String>

ReturnValue

Name Description
ContextMessage(this.value, this.messages + messages)

appendMessages

fun appendMessages(message: String): ContextMessage(this.value, this.messages + message)

Parameters

Name Description
message: String

ReturnValue

Name Description
ContextMessage(this.value, this.messages + message)

equals

fun equals(other: Any?): Boolean

Parameters

Name Description
other: Any?

ReturnValue

Name Description
Boolean

hashCode

fun hashCode(): Int

ReturnValue

Name Description
Int

Extensions

handleMessage

inline fun <V : Any> ContextMessage<V>.handleMessage(block: (List<String>)->Unit): V

Handle a message with block and then return only the ContextMessage.value.

Receiver

Name Description
ContextMessage<V>

ContextMessage to be handled

Parameters

Name Description
block: (List<String>)->Unit

the actual handler for the context message

ReturnValue

Name Description
V

only the remaining ContextMessage.value

map

inline fun <V : Any, R : Any> ContextMessage<V>.map(transform: (V)->R): ContextMessage<R>

Receiver

Name Description
ContextMessage<V>

Parameters

Name Description
transform: (V)->R

ReturnValue

Name Description
ContextMessage<R>