mirror of
https://github.com/zaaarf/geb-processor.git
synced 2024-11-26 00:04:50 +01:00
feat: implemented annotations
This commit is contained in:
parent
61e9b5c848
commit
25a6bac104
3 changed files with 66 additions and 0 deletions
17
src/main/java/ftbsc/geb/api/annotations/Event.java
Normal file
17
src/main/java/ftbsc/geb/api/annotations/Event.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package ftbsc.geb.api.annotations;
|
||||||
|
|
||||||
|
import ftbsc.geb.api.IEvent;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks a class as an Event. It should implement the {@link IEvent} interface.
|
||||||
|
* It doesn't need to be abstract, but it can never be final.
|
||||||
|
* @since 0.1.0
|
||||||
|
*/
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.CLASS)
|
||||||
|
public @interface Event {}
|
32
src/main/java/ftbsc/geb/api/annotations/Listen.java
Normal file
32
src/main/java/ftbsc/geb/api/annotations/Listen.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package ftbsc.geb.api.annotations;
|
||||||
|
|
||||||
|
import ftbsc.geb.api.IEvent;
|
||||||
|
import ftbsc.geb.api.IListener;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks the method as a listener. Its parent must implement the {@link IListener} interface.
|
||||||
|
* The annotated method should only take a single input value, an instance of {@link IEvent};
|
||||||
|
* it should be either void or boolean; if it's boolean, the return value indicates whether
|
||||||
|
* the event was canceled.
|
||||||
|
* @since 0.1.0
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.CLASS)
|
||||||
|
public @interface Listen {
|
||||||
|
/**
|
||||||
|
* @return an integer indicating priority level for the listener, defaulting to 0
|
||||||
|
*/
|
||||||
|
int priority() default 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an array of {@link String}s specifying which buses they should be listening on;
|
||||||
|
* an empty array means that they should listen on all buses, ignoring identifiers:
|
||||||
|
* that's probably what you wanted anyway.
|
||||||
|
*/
|
||||||
|
String[] on() default {}; //empty array = listen on all of them
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package ftbsc.geb.api.annotations;
|
||||||
|
|
||||||
|
import ftbsc.geb.api.IListener;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This annotation should mark either be a static instance of {@link IListener}
|
||||||
|
* or a static method returning one.
|
||||||
|
* @since 0.1.0
|
||||||
|
*/
|
||||||
|
@Target({ElementType.FIELD, ElementType.METHOD})
|
||||||
|
@Retention(RetentionPolicy.CLASS)
|
||||||
|
public @interface ListenerInstance {}
|
Loading…
Reference in a new issue