EventHandlerMeta { public boolean canHandle(Event event, @Nullable EventPriority priority) { return this.event.isInstance(event) && (priority == null || priority.equals(this.priority)) && !(event.isCancelled() && this.ignoreCancelled); } EventHandlerMeta(Class<T> event, EventPriority priority, boolean ignoreCancelled); Class<T> event(); EventPriority priority(); boolean ignoreCancelled(); boolean canHandle(Event event, @Nullable EventPriority priority); boolean canCall(Method method); void assertCanCall(Method method); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static EventHandlerMeta<T> forAnnotation(Class<T> event, EventHandler annotation); static @Nullable EventHandlerMeta<?> forMethod(Method method);  }
@Test public void canHandle() throws Throwable { EventHandlerMeta<TestEvent> meta = new EventHandlerMeta<>(TestEvent.class, EventPriority.NORMAL, false); assertTrue(meta.canHandle(new TestEvent(), null)); assertFalse(meta.canHandle(new Event(){}, null)); assertTrue(meta.canHandle(new TestEvent(){}, null)); assertTrue(meta.canHandle(new TestEvent(), EventPriority.NORMAL)); assertFalse(meta.canHandle(new TestEvent(), EventPriority.LOW)); TestEvent cancelled = new TestEvent(){ public boolean isCancelled() { return true; } }; assertTrue(meta.canHandle(cancelled, null)); assertFalse(new EventHandlerMeta<>(TestEvent.class, EventPriority.NORMAL, true).canHandle(cancelled, null)); }