Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Make EventHandler generic #4

Closed
fmbenhassine opened this issue Mar 3, 2020 · 1 comment
Closed

Make EventHandler generic #4

fmbenhassine opened this issue Mar 3, 2020 · 1 comment
Milestone

Comments

@fmbenhassine
Copy link
Member

As of v1.0.1, the EventHandler interface is not generic. This requires a cast when using custom events:

public class MyEvent extends Event {
    
}

public class MyEventHandler implements EventHandler {
	
	@Override
	public void handleEvent(Event event) throws Exception {
		if (event instanceof MyEvent) {
			MyEvent myEvent = (MyEvent) event;
			// do something with myEvent
		}
	}
}

The EventHandler interface should be something like:

public interface EventHandler<E extends Event> {
    void handleEvent(E event) throws Exception;
}

to eliminate the need to do the cast.

@fmbenhassine fmbenhassine added this to the v2.0.0 milestone Mar 3, 2020
@fmbenhassine
Copy link
Member Author

Implemented in 6b72eff

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant