Archived
0

Test code for cache-like event loop

This commit is contained in:
Daniil
2018-07-31 14:19:46 +07:00
parent 4332146556
commit 03974934a0
3 changed files with 38 additions and 0 deletions

View File

@@ -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){
}
}

View File

@@ -0,0 +1,5 @@
package mc.core.events.cachelike;
public @interface Preprocessor {
Class<PreprocessorContext> preprocessor();
}

View File

@@ -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() ;
}