tterrag1098

Untitled

Jun 16th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1.   /**
  2.    * Checks if the handler can handle the given type, and if so, returns an
  3.    * instance for handling it. This is ony used for handlers that are registered
  4.    * with the {@link Registry}.
  5.    *
  6.    * @param type
  7.    *          A type that wants to be handled
  8.    * @return An {@link IHandler} to handle the given type, if possible. <code>null</code otherwise.
  9.    */
  10.   default IHandler<? extends T> getHandler(Type type) {
  11.     return isAssignable(getRootType(), type) ? this : null;
  12.   }
  13.  
  14.   /**
  15.    * Utility method for simple handlers that handle a single class. Only used by
  16.    * {@link #getHandler(Type)}.
  17.    *
  18.    * @return The {@link #getClass()} this handler can handle.
  19.    */
  20.   default Class<?> getRootType() {
  21.     // Should be equivalent to null without being null. Nothing can extend, nor would use Void.
  22.     return Void.class;
  23.   }
Advertisement
Add Comment
Please, Sign In to add comment