Header

Represents the header of a message, containing metadata key-value pairs.

This interface extends MutableMap to provide standard map operations for header fields, and Copyable

to support creating copies of headers. It provides a fluent API for setting header values and supports read-only mode to prevent modifications after the header is finalized.

Headers are typically used to store metadata such as correlation IDs, timestamps, routing information, and other contextual data that accompanies the message body. Once a header is marked as read-only, any attempt to modify it will result in an UnsupportedOperationException being thrown.

Author

ahoo wang

See also

DefaultHeader

for the default implementation

for usage in message contexts

Properties

Link copied to clipboard
Link copied to clipboard
abstract val isReadOnly: Boolean

Indicates whether this header is in read-only mode.

Link copied to clipboard
abstract override val keys: MutableSet<String>
Link copied to clipboard
abstract val size: Int
Link copied to clipboard
abstract override val values: MutableCollection<String>

Functions

Link copied to clipboard
abstract fun clear()
Link copied to clipboard
abstract fun containsKey(key: String): Boolean
Link copied to clipboard
abstract fun containsValue(value: String): Boolean
Link copied to clipboard
abstract fun copy(): Header

Creates and returns a copy of the current object.

Link copied to clipboard
abstract operator fun get(key: String): String?
Link copied to clipboard
abstract fun isEmpty(): Boolean
Link copied to clipboard
abstract fun put(key: String, value: String): String?
Link copied to clipboard
abstract fun putAll(from: Map<out String, String>)
Link copied to clipboard

Extension function to convert a MutableMap to a SimpleDynamicDocument.

Link copied to clipboard
open fun with(additional: Map<String, String>): Header

Adds all key-value pairs from the provided map to this header and returns the header for method chaining.

open fun with(key: String, value: String): Header

Adds a key-value pair to this header and returns the header for method chaining.

Link copied to clipboard
abstract fun withReadOnly(): Header

Marks this header as read-only and returns it for method chaining.