aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/apt/Processor.java
blob: 5cae88a0147326777b1e584b11ceda71b46a5247 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
	}
}