Advertisement
tomdodd4598

Untitled

Oct 14th, 2021
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1.     @FunctionalInterface
  2.     protected static interface ExecutorToken2BooleanFunction<T extends Token> {
  3.        
  4.         boolean apply(Executor exec, T token);
  5.     }
  6.    
  7.     protected static class TokenFunctionMap {
  8.        
  9.         protected final Map<Class<? extends Token>, ExecutorToken2BooleanFunction<?>> internalMap = new HashMap<>();
  10.        
  11.         protected <T extends Token> void put(Class<T> clazz, ExecutorToken2BooleanFunction<T> function) {
  12.             internalMap.put(clazz, function);
  13.         }
  14.        
  15.         protected <T extends Token> ExecutorToken2BooleanFunction<T> get(Class<T> clazz) {
  16.             return (ExecutorToken2BooleanFunction<T>) internalMap.get(clazz);
  17.         }
  18.        
  19.         protected <T extends Token> boolean apply(Executor exec, T token) {
  20.             return get((Class<T>) token.getClass()).apply(exec, token);
  21.         }
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement