aboutsummaryrefslogtreecommitdiff
path: root/src/bindings/mapstruct/lombok/mapstruct/NotifierHider.java
blob: a8e92b4b9c21267380ae09bebf3a198a43099240 (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
package lombok.mapstruct;

import java.lang.reflect.Field;

import javax.lang.model.type.TypeMirror;

import org.mapstruct.ap.spi.AstModifyingAnnotationProcessor;

class NotifierHider {
	
	public static class AstModificationNotifier implements AstModifyingAnnotationProcessor {
		private static Field lombokInvoked;
		
		@Override public boolean isTypeComplete(TypeMirror type) {
			if (System.getProperty("lombok.disable") != null) return true;
			return isLombokInvoked();
		}
		
		private static boolean isLombokInvoked() {
			if (lombokInvoked != null) {
				try {
					return lombokInvoked.getBoolean(null);
				} catch (Exception e) {}
				return true;
			}
			
			try {
				Class<?> data = Class.forName("lombok.launch.AnnotationProcessorHider$AstModificationNotifierData");
				lombokInvoked = data.getField("lombokInvoked");
				return lombokInvoked.getBoolean(null);
			} catch (Exception e) {}
			return true;
		}
	}
}