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 newHeaderInformationobject with empty headers.HeaderInformation(io.vertx.core.eventbus.DeliveryOptions options)Creates a newHeaderInformationobject with the headers from theDeliveryOptions.HeaderInformation(io.vertx.core.eventbus.Message<?> message)Creates a newHeaderInformationobject with the headers from theVert.x message.HeaderInformation(io.vertx.core.MultiMap headers)Creates a newHeaderInformationobject with the providedVert.x headers. -
Method Summary
Modifier and TypeMethodDescriptionAppends multipleBooleanvalues assigned to the key.Appends multipleBytevalues assigned to the key.Appends multipleCharactervalues assigned to the key.Appends multipleDoublevalues assigned to the key.Appends multipleFloatvalues assigned to the key.Appends multipleIntegervalues assigned to the key.Appends multipleLongvalues assigned to the key.Appends multipleStringvalues assigned to the key.addAll(HeaderInformation information)Appends all values assigned to their keys from theHeaderInformationobject to already existing values.addAll(io.vertx.core.MultiMap headers)Appends all values assigned to their keys from theMultiMapto already existing values.Appends all values assigned to their keys from theMapto already existing values.io.vertx.core.eventbus.DeliveryOptionsattach(io.vertx.core.eventbus.DeliveryOptions options)Attaches the wrappedVert.x headersto theDeliveryOptionsand return them again for further usage.clear()Clears all values assigned to their keys.booleanReturnstrue, if at least one value is assigned to the key.booleanstatic HeaderInformationfrom(io.vertx.core.eventbus.DeliveryOptions options)Creates a newHeaderInformationobject fromDeliveryOptions.static HeaderInformationfrom(io.vertx.core.eventbus.Message<?> message)Creates a newHeaderInformationobject from aVert.x message.static HeaderInformationfrom(io.vertx.core.MultiMap headers)Creates a newHeaderInformationobject 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.booleangetBoolean(String key, boolean defaultValue)Returns the first stored value assigned to the key asBoolean.Returns the first stored value assigned to the key asByte.byteReturns the first stored value assigned to the key asByte.Returns the first stored value assigned to the key asCharacter.charReturns the first stored value assigned to the key asCharacter.Returns the first stored value assigned to the key asDouble.doubleReturns the first stored value assigned to the key asDouble.Returns the first stored value assigned to the key asFloat.floatReturns the first stored value assigned to the key asFloat.io.vertx.core.MultiMapReturns the wrappedVert.x headersready to use inDeliveryOptionsor theWithEventBusverticle trait.Returns the first stored value assigned to the key asInteger.intReturns the first stored value assigned to the key asInteger.Returns the first stored value assigned to the key asLong.longReturns the first stored value assigned to the key asLong.inthashCode()booleanisEmpty()Returnstrue, if the wrappedVert.x headershave no entries.static HeaderInformationmerge(HeaderInformation... information)Merges an array ofHeaderInformationobjects into oneHeaderInformationobject.static HeaderInformationmerge(List<HeaderInformation> list)Merges a list ofHeaderInformationobjects into oneHeaderInformationobject.static HeaderInformationmerge(Stream<HeaderInformation> stream)Merges a stream ofHeaderInformationobjects into oneHeaderInformationobject.names()Returns an immutable set of all keys which have values assigned to.Removes all values assigned to the key.Replaces multipleBooleanvalues with the old allocation assigned to the key.Replaces multipleBytevalues with the old allocation assigned to the key.Replaces multipleCharactervalues with the old allocation assigned to the key.Replaces multipleDoublevalues with the old allocation assigned to the key.Replaces multipleFloatvalues with the old allocation assigned to the key.Replaces multipleIntegervalues with the old allocation assigned to the key.Replaces multipleLongvalues with the old allocation assigned to the key.Replaces multipleStringvalues with the old allocation assigned to the key.setAll(HeaderInformation information)Replaces all values assigned to their keys with the content of theHeaderInformationobject.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.intsize()Returns the number of all keys which have values assigned to.io.vertx.core.eventbus.DeliveryOptionsCreates new and emptyDeliveryOptionsand attaches the wrappedVert.x headersto them.toString()
-
Constructor Details
-
HeaderInformation
public HeaderInformation()Creates a newHeaderInformationobject with empty headers.- See Also:
MultiMap.caseInsensitiveMultiMap()
-
HeaderInformation
public HeaderInformation(io.vertx.core.MultiMap headers)Creates a newHeaderInformationobject with the providedVert.x headers.- Parameters:
headers- theVert.x headersthat you want to wrap inside theHeaderInformationobject
-
HeaderInformation
public HeaderInformation(io.vertx.core.eventbus.Message<?> message)Creates a newHeaderInformationobject with the headers from theVert.x message.- Parameters:
message- theVert.x messagethat contains theVert.x headerswhich you want to wrap inside theHeaderInformationobject
-
HeaderInformation
public HeaderInformation(io.vertx.core.eventbus.DeliveryOptions options)Creates a newHeaderInformationobject with the headers from theDeliveryOptions.- Parameters:
options- theDeliveryOptionsthat contain theVert.x headerswhich you want to wrap inside theHeaderInformationobject
-
-
Method Details
-
merge
Merges an array ofHeaderInformationobjects into oneHeaderInformationobject.- Parameters:
information- multipleHeaderInformationobjects you want to merge- Returns:
- the merged
HeaderInformationobject
-
merge
Merges a list ofHeaderInformationobjects into oneHeaderInformationobject.- Parameters:
list- multipleHeaderInformationobjects you want to merge- Returns:
- the merged
HeaderInformationobject
-
merge
Merges a stream ofHeaderInformationobjects into oneHeaderInformationobject.- Parameters:
stream- a stream that contains multipleHeaderInformationobjects you want to merge- Returns:
- the merged
HeaderInformationobject
-
from
Creates a newHeaderInformationobject from existingVert.x headers.- Parameters:
headers- theVert.x headersyou want to wrap into theHeaderInformationobject- Returns:
- a new
HeaderInformationobject with the wrappedVert.x headers
-
from
Creates a newHeaderInformationobject from aVert.x message.- Parameters:
message- theVert.x messagethat contains theVert.x headersyou want to wrap into theHeaderInformationobject- Returns:
- a new
HeaderInformationobject with theVert.x headersfrom theVert.x message
-
from
Creates a newHeaderInformationobject fromDeliveryOptions.- Parameters:
options-DeliveryOptionsthat contain theVert.x headersyou want to wrap into theHeaderInformationobject- Returns:
- a new
HeaderInformationobject with theVert.x headersfrom theDeliveryOptions
-
getHeaders
public io.vertx.core.MultiMap getHeaders()Returns the wrappedVert.x headersready to use inDeliveryOptionsor theWithEventBusverticle 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 headersto theDeliveryOptionsand return them again for further usage.- Parameters:
options- theDeliveryOptionsthat receive the wrappedVert.x headers- Returns:
- the
DeliveryOptionsfor further usage
-
toOptions
public io.vertx.core.eventbus.DeliveryOptions toOptions()Creates new and emptyDeliveryOptionsand attaches the wrappedVert.x headersto them.- Returns:
- the new
DeliveryOptionswith the attachedVert.x headers
-
get
Returns the first stored value assigned to the key asString. If no value is assigned to the key, anempty Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 Optionalis returned instead.- Parameters:
key- the key to which the value is assigned- Returns:
- the first stored value wrapped inside an
Optionalfor betternulltype 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 multipleStringvalues assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newStringvalues 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 multipleBytevalues assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newBytevalues 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 multipleIntegervalues assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newIntegervalues 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 multipleLongvalues assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newLongvalues 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 multipleFloatvalues assigned to the key. Return a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newFloatvalues 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 multipleDoublevalues assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newDoublevalues 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 multipleCharactervalues assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newCharactervalues 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 multipleBooleanvalues assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newBooleanvalues 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 theMultiMapto already existing values. Returns a reference tothisfor fluent design.- Parameters:
headers- theMultiMapthat 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 theMapto already existing values. Returns a reference tothisfor fluent design.- Parameters:
headers- theMapthat 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 theHeaderInformationobject to already existing values. Returns a reference tothisfor fluent design.- Parameters:
information- theHeaderInformationobject 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 multipleStringvalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newStringvalues 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 multipleBytevalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newBytevalues 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 multipleIntegervalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newIntegervalues 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 multipleLongvalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newLongvalues 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 multipleFloatvalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newFloatvalues 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 multipleDoublevalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newDoublevalues 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 multipleCharactervalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newCharactervalues 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 multipleBooleanvalues with the old allocation assigned to the key. Returns a reference tothisfor fluent design.- Parameters:
key- the key to which the values are assignedvalues- the newBooleanvalues 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 entireMultiMapinstance.
Returns a reference tothisfor fluent design.- Parameters:
headers- theMultiMapthat 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 entireMultiMapinstance.
Returns a reference tothisfor fluent design.- Parameters:
headers- theMapthat 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 theHeaderInformationobject. All other existing key slots are cleared. It is effectively an entire replacement of the entireMultiMapinstance.
Returns a reference tothisfor fluent design.- Parameters:
information- theHeaderInformationobject 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,falseis 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 tothisfor 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 tothisfor 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 headershave no entries.- Returns:
trueif the wrappedVert.x headershave no entries- See Also:
MultiMap.isEmpty()
-
toString
-
equals
-
hashCode
public int hashCode()
-