From 4f5f689bf2be42bc2a6e331ae83bace35c9e86e9 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 24 Aug 2012 15:17:46 +0200 Subject: There is now an 'override this method' alternative for setting the annotation you handle for an XAnnotationHandler; default behaviour still extracts the T part out of the signature. --- src/core/lombok/eclipse/EclipseAnnotationHandler.java | 10 ++++++++++ src/core/lombok/eclipse/HandlerLibrary.java | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/core/lombok/eclipse') diff --git a/src/core/lombok/eclipse/EclipseAnnotationHandler.java b/src/core/lombok/eclipse/EclipseAnnotationHandler.java index ca9cac83..84304339 100644 --- a/src/core/lombok/eclipse/EclipseAnnotationHandler.java +++ b/src/core/lombok/eclipse/EclipseAnnotationHandler.java @@ -22,6 +22,7 @@ package lombok.eclipse; import lombok.core.AnnotationValues; +import lombok.core.SpiLoadUtil; /** * Implement this interface if you want to be triggered for a specific annotation. @@ -59,4 +60,13 @@ public abstract class EclipseAnnotationHandler annotation, org.eclipse.jdt.internal.compiler.ast.Annotation ast, EclipseNode annotationNode) { } + + /** + * This handler is a handler for the given annotation; you don't normally need to override this class + * as the annotation type is extracted from your {@code extends EclipseAnnotationHandler} + * signature. + */ + @SuppressWarnings("unchecked") public Class getAnnotationHandledByThisHandler() { + return (Class) SpiLoadUtil.findAnnotationClass(getClass(), EclipseAnnotationHandler.class); + } } diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index 5f360f6f..bf01dc20 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -158,8 +158,7 @@ public class HandlerLibrary { try { for (EclipseAnnotationHandler handler : SpiLoadUtil.findServices(EclipseAnnotationHandler.class, EclipseAnnotationHandler.class.getClassLoader())) { try { - Class annotationClass = - SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class); + Class annotationClass = handler.getAnnotationHandledByThisHandler(); AnnotationHandlerContainer container = new AnnotationHandlerContainer(handler, annotationClass); String annotationClassName = container.annotationClass.getName().replace("$", "."); if (lib.annotationHandlers.put(annotationClassName, container) != null) { -- cgit