Replace priority with @Priority
The new @Priority annotation serves the exact same purpose as @Event(priority = ...), but should be easier to read in complex handler declarations. It has to be used in conjunction with the @Event annotation, not instead of it.
This commit is contained in:
@ -39,13 +39,15 @@ class CancelTest implements EventListener {
|
||||
assertEquals(1, hits);
|
||||
}
|
||||
|
||||
@Event(eventType = SimpleEvent.class, priority = 100)
|
||||
@Event(eventType = SimpleEvent.class)
|
||||
@Priority(100)
|
||||
void onSimpleFirst() {
|
||||
++hits;
|
||||
bus.cancel();
|
||||
}
|
||||
|
||||
@Event(eventType = SimpleEvent.class, priority = 50)
|
||||
@Event(eventType = SimpleEvent.class)
|
||||
@Priority(50)
|
||||
void onSimpleSecond() {
|
||||
++hits;
|
||||
}
|
||||
|
@ -38,20 +38,22 @@ class DispatchTest implements EventListener {
|
||||
bus.dispatch(new SimpleEvent());
|
||||
}
|
||||
|
||||
@Event(eventType = SimpleEvent.class, priority = 200)
|
||||
@Event(eventType = SimpleEvent.class)
|
||||
@Priority(200)
|
||||
@Polymorphic
|
||||
void onSimpleEventFirst() {
|
||||
++hits;
|
||||
assertTrue(hits == 1 || hits == 2);
|
||||
}
|
||||
|
||||
@Event(eventType = SimpleEvent.class, priority = 150)
|
||||
@Event(eventType = SimpleEvent.class)
|
||||
@Priority(150)
|
||||
static void onSimpleEventSecond() {
|
||||
++hits;
|
||||
assertEquals(3, hits);
|
||||
}
|
||||
|
||||
@Event(priority = 100)
|
||||
@Event
|
||||
void onSimpleEventThird(SimpleEvent event) {
|
||||
++hits;
|
||||
assertEquals(4, hits);
|
||||
|
Reference in New Issue
Block a user