Class AbstractMessage
java.lang.Object
io.gravitee.gateway.reactive.api.message.AbstractMessage
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
DefaultMessage
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TReturns the value of the attribute cast in the expected type T, ornullif no attribute for the given name exists.Stores an attribute in this message.<T> List<T>attributeAsList(String name) Return the attribute as an immutableList.Returns aSetcontaining the names of the attributes available to this message.Get all attributes available.<T> TinternalAttribute(String name) internalAttribute(String name, Object value) Stores an internal attribute in this message.Returns aSetcontaining the names of the internal attributes available to this message.Get all internal attributes available.metadata()Get the metadata of the message.removeAttribute(String name) Removes an attribute from this request.Removes an internal attribute from this request.longThe timestamp for when this message was created.unmodifiableMetadata(Map<String, Object> metadata)
-
Field Details
-
SOURCE_TIMESTAMP
- See Also:
-
timestamp
protected final long timestamp -
sourceTimestamp
protected final long sourceTimestamp -
metadata
-
attributes
-
internalAttributes
-
-
Constructor Details
-
AbstractMessage
-
-
Method Details
-
timestamp
public long timestamp()Description copied from interface:MessageThe timestamp for when this message was created. -
metadata
Description copied from interface:MessageGet the metadata of the message. Metadata are read-only. They usually come from the source that emits the message and can't be changed. -
attribute
Description copied from interface:MessageReturns the value of the attribute cast in the expected type T, ornullif no attribute for the given name exists.- Specified by:
attributein interfaceMessage- Type Parameters:
T- the expected type of the attribute value. SpecifyObjectif you expect value of any type.- Parameters:
name- the name of the attribute.- Returns:
- an Object containing the value of the attribute, or null if the attribute does not exist.
-
attributeAsList
Description copied from interface:MessageReturn the attribute as an immutableList. This method acts differently depending on the type of the attribute's value. Elements of theListare mapped as follows:For String:
- comma separated string are spitted and returned trimmed
- Parsable JSON Array elements are returned as strings (including objects)
- if none of the above, the string is simply wrapped
For Collection:
- Elements of the collection are wrapped in a new List
For Array:
- Each elements of the is wrapped into the returned List
For any other cases: the value is simply wrapped into the returned List. Notes: One calling
Message.attribute(String, Object)with a mutable collection will retrieve an immutable one.- Specified by:
attributeAsListin interfaceMessage- Type Parameters:
T- the expected type of the attribute value. SpecifyObjectif you expect value of any type.- Parameters:
name- the name of the attribute.- Returns:
- an immutable List with the attribute values.
-
attribute
Description copied from interface:MessageStores an attribute in this message. -
removeAttribute
Description copied from interface:MessageRemoves an attribute from this request. This method is not generally needed as attributes only persist as long as the message is being handled.- Specified by:
removeAttributein interfaceMessage- Parameters:
name- the name of the attribute to remove.- Returns:
- reference to itself for easily chain calls
-
attributeNames
Description copied from interface:MessageReturns aSetcontaining the names of the attributes available to this message. This method returns an emptySetif the message has no attributes available to it.- Specified by:
attributeNamesin interfaceMessage- Returns:
- a set of strings containing the names of the message's attributes.
-
attributes
Description copied from interface:MessageGet all attributes available.- Specified by:
attributesin interfaceMessage- Type Parameters:
T- the expected type of the attribute values. SpecifyObjectif you expect values of any types.- Returns:
- the list of all the attributes.
-
internalAttribute
- Specified by:
internalAttributein interfaceMessage
-
internalAttribute
Description copied from interface:MessageStores an internal attribute in this message. Internal attributes can be used to avoid mixin with attributes set by the user during the request processing.. You can safely use internal attribute to temporary store useful objects required during different phases of the execution.- Specified by:
internalAttributein interfaceMessage- Parameters:
name- a String specifying the name of the attribute.value- the Object to be stored.Returns:- Returns:
- reference to itself for easily chain calls
-
removeInternalAttribute
Description copied from interface:MessageRemoves an internal attribute from this request. This method is not generally needed as internal attributes only persist as long as the message is being handled.- Specified by:
removeInternalAttributein interfaceMessage- Parameters:
name- the name of the internal attribute to remove.- Returns:
- reference to itself for easily chain calls.
-
internalAttributeNames
Description copied from interface:MessageReturns aSetcontaining the names of the internal attributes available to this message. This method returns an emptySetif the message has no internal attributes available to it.- Specified by:
internalAttributeNamesin interfaceMessage- Returns:
- a set of strings containing the names of the message's internal attributes.
-
internalAttributes
Description copied from interface:MessageGet all internal attributes available. Internal attributes are not intended to be manipulated by end-users. You can safely use internal attribute to temporary store useful objects required during different phases of the execution.- Specified by:
internalAttributesin interfaceMessage- Type Parameters:
T- the expected type of the internal attribute values. SpecifyObjectif you expect values of any types.- Returns:
- the list of all the internal attributes.
-
unmodifiableMetadata
-