aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/apt/Processor.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-06-08 22:26:30 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-06-08 22:26:30 +0200
commit1677c4a52a0aea1b955f7c2c7d096903d4a8c5ce (patch)
tree29de8d12d774f026c0f317e229532befaeb2d096 /src/lombok/apt/Processor.java
downloadlombok-1677c4a52a0aea1b955f7c2c7d096903d4a8c5ce.tar.gz
lombok-1677c4a52a0aea1b955f7c2c7d096903d4a8c5ce.tar.bz2
lombok-1677c4a52a0aea1b955f7c2c7d096903d4a8c5ce.zip
Initial commit. As a proof of concept, it already works in javac and eclipse!
Diffstat (limited to 'src/lombok/apt/Processor.java')
-rw-r--r--src/lombok/apt/Processor.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/lombok/apt/Processor.java b/src/lombok/apt/Processor.java
new file mode 100644
index 00000000..5cae88a0
--- /dev/null
+++ b/src/lombok/apt/Processor.java
@@ -0,0 +1,36 @@
+package lombok.apt;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+
+import lombok.Getter;
+
+
+@SupportedAnnotationTypes("lombok.*")
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class Processor extends AbstractProcessor {
+ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ for ( TypeElement typeElement : annotations ) {
+ if ( typeElement.getQualifiedName().contentEquals(Getter.class.getName()) )
+ return handle(roundEnv, Getter.class, typeElement);
+ }
+
+ return false;
+ }
+
+ private <T extends Annotation> boolean handle(RoundEnvironment roundEnv, Class<T> annotation, TypeElement typeElement) {
+ for ( Element element : roundEnv.getElementsAnnotatedWith(typeElement) ) {
+ new AnnotationTransponder<T>(annotation, roundEnv, processingEnv).handle(element, element.getAnnotation(annotation));
+ }
+ return true;
+ }
+}