Record Class Channel<T,R>
java.lang.Object
java.lang.Record
org.nanonative.nano.helper.event.model.Channel<T,R>
Publish/subscribe channel used to route events between components.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Channel<?, ?> channelOf(int id) Retrieves the name of an eventChannelgiven its id.Attempts to find theChannelbased on its name.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intid()Returns the value of theidrecord component.static booleanisChannelIdAvailable(int id) Checks if aChannelwith the given id exists.name()Returns the value of thenamerecord component.payload()Returns the value of thepayloadrecord component.registerChannelId(String name) Registers a newChannelwith a given name if it does not already exist.registerChannelId(String name, Class<C> payload) Registers a newChannelwith a given name if it does not already exist.static <C,R> Channel <C, R> registerChannelId(String name, Class<C> type, Class<R> response) Registers a newChannelwith a given name if it does not already exist.response()Returns the value of theresponserecord component.toString()Performs the toString operation.
-
Constructor Details
-
Channel
Creates an instance of aChannelrecord class.- Parameters:
id- the value for theidrecord componentname- the value for thenamerecord componentpayload- the value for thepayloadrecord componentresponse- the value for theresponserecord component
-
-
Method Details
-
registerChannelId
-
registerChannelId
-
registerChannelId
-
channelOf
Attempts to find theChannelbased on its name. This method is primarily used for debugging or startup purposes and is not optimized for performance. -
channelOf
Retrieves the name of an eventChannelgiven its id. -
isChannelIdAvailable
public static boolean isChannelIdAvailable(int id) Checks if aChannelwith the given id exists. -
toString
Performs the toString operation. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
public int id()Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
payload
Returns the value of thepayloadrecord component.- Returns:
- the value of the
payloadrecord component
-
response
Returns the value of theresponserecord component.- Returns:
- the value of the
responserecord component
-