Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save qzagarese/b4b513db4246d2d69527e2d5856f8d97 to your computer and use it in GitHub Desktop.
Save qzagarese/b4b513db4246d2d69527e2d5856f8d97 to your computer and use it in GitHub Desktop.
// Get the handler type from the @Handler annotation
Class<? extends AnnotationHandler> handlerType = annotation.annotationType().getAnnotation(Handler.class).value();
// Get and invoke the only constructor (which needs to be an empty one, unless you need a more complex behavior)
AnnotationHandler handler = (AnnotationHandler) Stream.of(handlerType.getConstructors())
.findFirst()
.get()
.newInstance(new Object[0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment