Test code for cache-like event loop
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package mc.core.events.cachelike;
|
||||||
|
|
||||||
|
import mc.core.events.LoginEvent;
|
||||||
|
|
||||||
|
public class SampleHandler {
|
||||||
|
|
||||||
|
@Preprocessor(preprocessor = (new PreprocessorContext<LoginEvent>() {
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}).class)
|
||||||
|
public void onLogin(LoginEvent event){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package mc.core.events.cachelike;
|
||||||
|
|
||||||
|
public @interface Preprocessor {
|
||||||
|
Class<PreprocessorContext> preprocessor();
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package mc.core.events.cachelike;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class PreprocessorContext<E> {
|
||||||
|
private List<Function<E, Number>> fetchers = new ArrayList<>();
|
||||||
|
|
||||||
|
protected void push(Function<E, Number> fetcher) {
|
||||||
|
fetchers.add(fetcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void init() ;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user