Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @FunctionalInterface
- protected static interface ExecutorToken2BooleanFunction<T extends Token> {
- boolean apply(Executor exec, T token);
- }
- protected static class TokenFunctionMap {
- protected final Map<Class<? extends Token>, ExecutorToken2BooleanFunction<?>> internalMap = new HashMap<>();
- protected <T extends Token> void put(Class<T> clazz, ExecutorToken2BooleanFunction<T> function) {
- internalMap.put(clazz, function);
- }
- protected <T extends Token> ExecutorToken2BooleanFunction<T> get(Class<T> clazz) {
- return (ExecutorToken2BooleanFunction<T>) internalMap.get(clazz);
- }
- protected <T extends Token> boolean apply(Executor exec, T token) {
- return get((Class<T>) token.getClass()).apply(exec, token);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement