Class HeaderInformation
java.lang.Object
de.wuespace.telestion.api.message.HeaderInformation
- Direct Known Subclasses:
DelayCounterInformation
,TimeInformation
Description
The HeaderInformation
class wraps APIs to attach information to messages
to transfer them over the Vert.x event bus
.
This implementation extends the already existing functionality of the Vert.x message headers
to allow storing and retrieving of other basic data types than String
.
Usage
public class MyVerticle extends TelestionVerticle<GenericConfiguration> implements WithEventBus {
@Override
public void onStart() {
var requestInfos = new HeaderInformation()
.add("version", 1)
.add("log-enabled", true)
.add("my-initial-char", 'C').
.add("my-coworkers-name", "fussel178");
request("request-address", "Hello with Info", requestInfos).onSuccess(message -> {
var responseInfos = HeaderInformation.from(message);
logger.info("Received version: {}", responseInfos.getInt("version", -1));
logger.info("Received log enabled state: {}", responseInfos.getBoolean("log-enabled", false));
logger.info("Received initial char: {}", responseInfos.getChar("my-initial-char", '\0'));
logger.info("Received coworker name: {}", responseInfos.get("my-coworkers-name", "unset"));
});
}
}
- See Also:
WithEventBus
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newHeaderInformation
object with empty headers.HeaderInformation(io.vertx.core.eventbus.DeliveryOptions options)
Creates a newHeaderInformation
object with the headers from theDeliveryOptions
.HeaderInformation(io.vertx.core.eventbus.Message<?> message)
Creates a newHeaderInformation
object with the headers from theVert.x message
.HeaderInformation(io.vertx.core.MultiMap headers)
Creates a newHeaderInformation
object with the providedVert.x headers
. -
Method Summary
Modifier and TypeMethodDescriptionAppends multipleBoolean
values assigned to the key.Appends multipleByte
values assigned to the key.Appends multipleCharacter
values assigned to the key.Appends multipleDouble
values assigned to the key.Appends multipleFloat
values assigned to the key.Appends multipleInteger
values assigned to the key.Appends multipleLong
values assigned to the key.Appends multipleString
values assigned to the key.addAll(HeaderInformation information)
Appends all values assigned to their keys from theHeaderInformation
object to already existing values.addAll(io.vertx.core.MultiMap headers)
Appends all values assigned to their keys from theMultiMap
to already existing values.Appends all values assigned to their keys from theMap
to already existing values.io.vertx.core.eventbus.DeliveryOptions
attach(io.vertx.core.eventbus.DeliveryOptions options)
Attaches the wrappedVert.x headers
to theDeliveryOptions
and return them again for further usage.clear()
Clears all values assigned to their keys.boolean
Returnstrue
, if at least one value is assigned to the key.boolean
static HeaderInformation
from(io.vertx.core.eventbus.DeliveryOptions options)
Creates a newHeaderInformation
object fromDeliveryOptions
.static HeaderInformation
from(io.vertx.core.eventbus.Message<?> message)
Creates a newHeaderInformation
object from aVert.x message
.static HeaderInformation
from(io.vertx.core.MultiMap headers)
Creates a newHeaderInformation
object from existingVert.x headers
.Returns the first stored value assigned to the key asString
.Returns the first stored value assigned to the key asString
.Returns a list of all stored values assigned to the key as a list ofStrings
.getBoolean(String key)
Returns the first stored value assigned to the key asBoolean
.boolean
getBoolean(String key, boolean defaultValue)
Returns the first stored value assigned to the key asBoolean
.Returns the first stored value assigned to the key asByte
.byte
Returns the first stored value assigned to the key asByte
.Returns the first stored value assigned to the key asCharacter
.char
Returns the first stored value assigned to the key asCharacter
.Returns the first stored value assigned to the key asDouble
.double
Returns the first stored value assigned to the key asDouble
.Returns the first stored value assigned to the key asFloat
.float
Returns the first stored value assigned to the key asFloat
.io.vertx.core.MultiMap
Returns the wrappedVert.x headers
ready to use inDeliveryOptions
or theWithEventBus
verticle trait.Returns the first stored value assigned to the key asInteger
.int
Returns the first stored value assigned to the key asInteger
.Returns the first stored value assigned to the key asLong
.long
Returns the first stored value assigned to the key asLong
.int
hashCode()
boolean
isEmpty()
Returnstrue
, if the wrappedVert.x headers
have no entries.static HeaderInformation
merge(HeaderInformation... information)
Merges an array ofHeaderInformation
objects into oneHeaderInformation
object.static HeaderInformation
merge(List<HeaderInformation> list)
Merges a list ofHeaderInformation
objects into oneHeaderInformation
object.static HeaderInformation
merge(Stream<HeaderInformation> stream)
Merges a stream ofHeaderInformation
objects into oneHeaderInformation
object.names()
Returns an immutable set of all keys which have values assigned to.Removes all values assigned to the key.Replaces multipleBoolean
values with the old allocation assigned to the key.Replaces multipleByte
values with the old allocation assigned to the key.Replaces multipleCharacter
values with the old allocation assigned to the key.Replaces multipleDouble
values with the old allocation assigned to the key.Replaces multipleFloat
values with the old allocation assigned to the key.Replaces multipleInteger
values with the old allocation assigned to the key.Replaces multipleLong
values with the old allocation assigned to the key.Replaces multipleString
values with the old allocation assigned to the key.setAll(HeaderInformation information)
Replaces all values assigned to their keys with the content of theHeaderInformation
object.setAll(io.vertx.core.MultiMap headers)
Replaces all values assigned to their keys with the content of theMultiMap
.Replaces all values assigned to their keys with the content of theMap
.int
size()
Returns the number of all keys which have values assigned to.io.vertx.core.eventbus.DeliveryOptions
Creates new and emptyDeliveryOptions
and attaches the wrappedVert.x headers
to them.toString()
-
Constructor Details
-
HeaderInformation
public HeaderInformation()Creates a newHeaderInformation
object with empty headers.- See Also:
MultiMap.caseInsensitiveMultiMap()
-
HeaderInformation
public HeaderInformation(io.vertx.core.MultiMap headers)Creates a newHeaderInformation
object with the providedVert.x headers
.- Parameters:
headers
- theVert.x headers
that you want to wrap inside theHeaderInformation
object
-
HeaderInformation
public HeaderInformation(io.vertx.core.eventbus.Message<?> message)Creates a newHeaderInformation
object with the headers from theVert.x message
.- Parameters:
message
- theVert.x message
that contains theVert.x headers
which you want to wrap inside theHeaderInformation
object
-
HeaderInformation
public HeaderInformation(io.vertx.core.eventbus.DeliveryOptions options)Creates a newHeaderInformation
object with the headers from theDeliveryOptions
.- Parameters:
options
- theDeliveryOptions
that contain theVert.x headers
which you want to wrap inside theHeaderInformation
object
-
-
Method Details
-
merge
Merges an array ofHeaderInformation
objects into oneHeaderInformation
object.- Parameters:
information
- multipleHeaderInformation
objects you want to merge- Returns:
- the merged
HeaderInformation
object
-
merge
Merges a list ofHeaderInformation
objects into oneHeaderInformation
object.- Parameters:
list
- multipleHeaderInformation
objects you want to merge- Returns:
- the merged
HeaderInformation
object
-
merge
Merges a stream ofHeaderInformation
objects into oneHeaderInformation
object.- Parameters:
stream
- a stream that contains multipleHeaderInformation
objects you want to merge- Returns:
- the merged
HeaderInformation
object
-
from
Creates a newHeaderInformation
object from existingVert.x headers
.- Parameters:
headers
- theVert.x headers
you want to wrap into theHeaderInformation
object- Returns:
- a new
HeaderInformation
object with the wrappedVert.x headers
-
from
Creates a newHeaderInformation
object from aVert.x message
.- Parameters:
message
- theVert.x message
that contains theVert.x headers
you want to wrap into theHeaderInformation
object- Returns:
- a new
HeaderInformation
object with theVert.x headers
from theVert.x message
-
from
Creates a newHeaderInformation
object fromDeliveryOptions
.- Parameters:
options
-DeliveryOptions
that contain theVert.x headers
you want to wrap into theHeaderInformation
object- Returns:
- a new
HeaderInformation
object with theVert.x headers
from theDeliveryOptions
-
getHeaders
public io.vertx.core.MultiMap getHeaders()Returns the wrappedVert.x headers
ready to use inDeliveryOptions
or theWithEventBus
verticle trait.- Returns:
- the wrapped
Vert.x headers
-
attach
public io.vertx.core.eventbus.DeliveryOptions attach(io.vertx.core.eventbus.DeliveryOptions options)Attaches the wrappedVert.x headers
to theDeliveryOptions
and return them again for further usage.- Parameters:
options
- theDeliveryOptions
that receive the wrappedVert.x headers
- Returns:
- the
DeliveryOptions
for further usage
-
toOptions
public io.vertx.core.eventbus.DeliveryOptions toOptions()Creates new and emptyDeliveryOptions
and attaches the wrappedVert.x headers
to them.- Returns:
- the new
DeliveryOptions
with the attachedVert.x headers
-
get
Returns the first stored value assigned to the key asString
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
get
Returns the first stored value assigned to the key asString
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getByte
Returns the first stored value assigned to the key asByte
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
getByte
Returns the first stored value assigned to the key asByte
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getInt
Returns the first stored value assigned to the key asInteger
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
getInt
Returns the first stored value assigned to the key asInteger
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getLong
Returns the first stored value assigned to the key asLong
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
getLong
Returns the first stored value assigned to the key asLong
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getFloat
Returns the first stored value assigned to the key asFloat
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
getFloat
Returns the first stored value assigned to the key asFloat
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getDouble
Returns the first stored value assigned to the key asDouble
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
getDouble
Returns the first stored value assigned to the key asDouble
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getChar
Returns the first stored value assigned to the key asCharacter
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
getChar
Returns the first stored value assigned to the key asCharacter
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getBoolean
Returns the first stored value assigned to the key asBoolean
. If no value is assigned to the key, anempty Optional
is returned instead.- Parameters:
key
- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optional
for betternull
type safety - See Also:
MultiMap.get(String)
-
getBoolean
Returns the first stored value assigned to the key asBoolean
. If no value is assigned to the key, the default value is used instead.- Parameters:
key
- the key to which the value is assigneddefaultValue
- the value which is returned if no value is assigned to the key- Returns:
- the first stored value or the default value if no value is assigned to the key
- See Also:
MultiMap.get(String)
-
getAll
Returns a list of all stored values assigned to the key as a list ofStrings
.- Parameters:
key
- the key to which the values are assigned- Returns:
- all stored values as a list of
Strings
- See Also:
MultiMap.getAll(String)
-
add
Appends multipleString
values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newString
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
add
Appends multipleByte
values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newByte
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
add
Appends multipleInteger
values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newInteger
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
add
Appends multipleLong
values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newLong
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
add
Appends multipleFloat
values assigned to the key. Return a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newFloat
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
add
Appends multipleDouble
values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newDouble
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
add
Appends multipleCharacter
values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newCharacter
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
add
Appends multipleBoolean
values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newBoolean
values that you want to append to the key- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.add(String, Iterable)
-
addAll
Appends all values assigned to their keys from theMultiMap
to already existing values. Returns a reference tothis
for fluent design.- Parameters:
headers
- theMultiMap
that contains the new values which you want to append to the existing values- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.addAll(MultiMap)
-
addAll
Appends all values assigned to their keys from theMap
to already existing values. Returns a reference tothis
for fluent design.- Parameters:
headers
- theMap
that contains the new values which you want to append to the existing values- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.addAll(Map)
-
addAll
Appends all values assigned to their keys from theHeaderInformation
object to already existing values. Returns a reference tothis
for fluent design.- Parameters:
information
- theHeaderInformation
object that contains the new values which you want to append to the existing values- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.addAll(MultiMap)
-
set
Replaces multipleString
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newString
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
set
Replaces multipleByte
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newByte
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
set
Replaces multipleInteger
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newInteger
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
set
Replaces multipleLong
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newLong
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
set
Replaces multipleFloat
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newFloat
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
set
Replaces multipleDouble
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newDouble
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
set
Replaces multipleCharacter
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newCharacter
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
set
Replaces multipleBoolean
values with the old allocation assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assignedvalues
- the newBoolean
values that you want to replace with the old allocation- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.set(String, Iterable)
-
setAll
Replaces all values assigned to their keys with the content of theMultiMap
. All remaining values are cleared. It is effectively an entire replacement of the entireMultiMap
instance.
Returns a reference tothis
for fluent design.- Parameters:
headers
- theMultiMap
that contains the new values assigned to their keys- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.setAll(MultiMap)
-
setAll
Replaces all values assigned to their keys with the content of theMap
. All remaining values are cleared. It is effectively an entire replacement of the entireMultiMap
instance.
Returns a reference tothis
for fluent design.- Parameters:
headers
- theMap
that contains the new values assigned to their keys- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.setAll(Map)
-
setAll
Replaces all values assigned to their keys with the content of theHeaderInformation
object. All other existing key slots are cleared. It is effectively an entire replacement of the entireMultiMap
instance.
Returns a reference tothis
for fluent design.- Parameters:
information
- theHeaderInformation
object that contains the new values assigned to their keys- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
setAll(MultiMap)
-
contains
Returnstrue
, if at least one value is assigned to the key. If no value is assigned,false
is returned instead.- Parameters:
key
- the key to which the value can be assigned- Returns:
true
, if at least one value is assigned to the key
-
remove
Removes all values assigned to the key. Returns a reference tothis
for fluent design.- Parameters:
key
- the key to which the values are assigned- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.remove(String)
-
clear
Clears all values assigned to their keys. Returns a reference tothis
for fluent design.- Returns:
- a reference to
this
, so the API can be used fluently - See Also:
MultiMap.clear()
-
size
public int size()Returns the number of all keys which have values assigned to.- Returns:
- the number of all keys which have values assigned to
- See Also:
MultiMap.size()
-
names
Returns an immutable set of all keys which have values assigned to.- Returns:
- an immutable set of all keys which have values assigned to
- See Also:
MultiMap.names()
-
isEmpty
public boolean isEmpty()Returnstrue
, if the wrappedVert.x headers
have no entries.- Returns:
true
if the wrappedVert.x headers
have no entries- See Also:
MultiMap.isEmpty()
-
toString
-
equals
-
hashCode
public int hashCode()
-