Package org.axonframework.messaging.core
Record Class SimpleEntry<M extends Message>
java.lang.Object
java.lang.Record
org.axonframework.messaging.core.SimpleEntry<M>
- Type Parameters:
M- The type ofMessagecontained in thisMessageStream.Entryimplementation.- Record Components:
message- TheMessageof typeMcontained in thisMessageStream.Entry.context- Maintains additional contextual information of this entry.
- All Implemented Interfaces:
Context,MessageStream.Entry<M>
public record SimpleEntry<M extends Message>(@Nullable M extends Message message, @Nonnull Context context)
extends Record
implements MessageStream.Entry<M>
Simple implementation of the
MessageStream.Entry containing a single Message implementation of type M and a
Context.- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.core.Context
Context.ResourceKey<T> -
Constructor Summary
ConstructorsConstructorDescriptionSimpleEntry(M message) Construct a SimpleEntry with the givenmessageand an emptyContext.SimpleEntry(M message, Context context) Compact construct asserting thecontextis notnull. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsResource(Context.ResourceKey<?> key) Indicates whether a resource has been registered with the givenkeyin this Context.context()Returns the value of thecontextrecord component.final booleanIndicates whether some other object is "equal to" this one.<T> TgetResource(Context.ResourceKey<T> key) Returns the resource currently registered under the givenkey, ornullif no resource is present.final inthashCode()Returns a hash code value for this object.<RM extends Message>
MessageStream.Entry<RM> Maps theMessageStream.Entry.message()by running it through the givenmapper.message()Returns the value of themessagerecord component.Retrieves all resources contained within the currentContext.final StringtoString()Returns a string representation of this record class.<T> MessageStream.Entry<M> withResource(Context.ResourceKey<T> key, T resource) Constructs a copy ofthisContext with an additionalresourcefor givenkey.
-
Constructor Details
-
SimpleEntry
Construct a SimpleEntry with the givenmessageand an emptyContext.- Parameters:
message- TheMessageof typeMcontained in thisMessageStream.Entry.
-
SimpleEntry
Compact construct asserting thecontextis notnull.- Parameters:
message- The message for this entrycontext- The context for this entry
-
-
Method Details
-
map
Description copied from interface:MessageStream.EntryMaps theMessageStream.Entry.message()by running it through the givenmapper. This adjusts the containedMessageStream.Entry.message()into aMessageimplementation of typeRM.- Specified by:
mapin interfaceMessageStream.Entry<M extends Message>- Type Parameters:
RM- The declared type ofMessageresulting from the givenmapper.- Parameters:
mapper- AFunctionmapping theMessageStream.Entry.message()of typeMto aMessageof typeRM.- Returns:
- The result of running the current
MessageStream.Entry.message()through the givenmapper.
-
containsResource
Description copied from interface:ContextIndicates whether a resource has been registered with the givenkeyin this Context.- Specified by:
containsResourcein interfaceContext- Parameters:
key- The key of the resource to check.- Returns:
trueif a resource is registered with thiskey, otherwisefalse.
-
getResource
Description copied from interface:ContextReturns the resource currently registered under the givenkey, ornullif no resource is present.- Specified by:
getResourcein interfaceContext- Type Parameters:
T- The type of resource registered under the givenkey.- Parameters:
key- The key to retrieve the resource for.- Returns:
- The resource currently registered under given
key, ornullif not present.
-
withResource
public <T> MessageStream.Entry<M> withResource(@Nonnull Context.ResourceKey<T> key, @Nonnull T resource) Description copied from interface:ContextConstructs a copy ofthisContext with an additionalresourcefor givenkey.- Specified by:
withResourcein interfaceContext- Specified by:
withResourcein interfaceMessageStream.Entry<M extends Message>- Type Parameters:
T- The type of resource registered under the givenkey.- Parameters:
key- The key under which to register theresource.resource- The resource to register.- Returns:
- A copy of
thisContext with the added givenresourcesunder the givenkeyto the copy.
-
resources
Description copied from interface:ContextRetrieves all resources contained within the currentContext.Most of the time, none of the keys make any sense to the component that would retrieve them. Thus, this method is purely here for copying resources between
Contextinstances, not for retrieval. For that, there's theContext.getResource(ResourceKey)method. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
message
Returns the value of themessagerecord component.- Specified by:
messagein interfaceMessageStream.Entry<M extends Message>- Returns:
- the value of the
messagerecord component
-
context
Returns the value of thecontextrecord component.- Returns:
- the value of the
contextrecord component
-