Brian Spindler wrote:yeah, I understand. unfortunately I'm consuming Events from an API which I have no control over.
How little control over the API do you have? Do you have the ability to add different Event Listeners for the different event types in whatever class(es) generate the event?
I mean, ideally:
Another option would be to map event handlers to the expected class name or event type name:
This has limitations on mapping an event on a per-class type, so there would be tight coupling between the event class and the handler class, not suitable if you don't know the exact classes of the events or want to code to some parent/interface type. A better solution would be to use names for the events, if that is possible with the API.