Package org.nanonative.nano.helper.event
Class EventChannelRegister
java.lang.Object
org.nanonative.nano.helper.event.EventChannelRegister
-
Method Summary
Modifier and TypeMethodDescriptionAttempts to find the ID of an event type based on its name.static StringeventNameOf(int channelId) Retrieves the name of an event type given its ID.static booleanisChannelIdAvailable(int channelId) Checks if an event type with the given ID exists.static intregisterChannelId(String channelName) Registers a new event type with a given name if it does not already exist.
-
Method Details
-
registerChannelId
Registers a new event type with a given name if it does not already exist. If the event type already exists, it returns the existing event type's ID.- Parameters:
channelName- The name of the event type to register.- Returns:
- The ID of the newly registered event type, or the ID of the existing event type if it already exists. Returns -1 if the input is null or empty.
-
eventNameOf
Retrieves the name of an event type given its ID.- Parameters:
channelId- The ID of the event type.- Returns:
- The name of the event type associated with the given ID, or null if not found.
-
eventIdOf
Attempts to find the ID of an event type based on its name. This method is primarily used for debugging or startup purposes and is not optimized for performance.- Parameters:
channelName- The name of the event type.- Returns:
- An
Optionalcontaining the ID of the event type if found, or empty if not found or if the input is null or empty.
-
isChannelIdAvailable
public static boolean isChannelIdAvailable(int channelId) Checks if an event type with the given ID exists.- Parameters:
channelId- The ID of the event type to check.- Returns:
- true if an event type with the given ID exists, false otherwise.
-