55import javax .annotation .processing .Filer ;
66import javax .annotation .processing .Messager ;
77import javax .annotation .processing .ProcessingEnvironment ;
8+ import javax .lang .model .SourceVersion ;
89import javax .lang .model .element .Element ;
910import javax .lang .model .element .TypeElement ;
1011import javax .lang .model .type .DeclaredType ;
1516import javax .tools .JavaFileObject ;
1617import java .io .IOException ;
1718
18- import static io .dinject .javalin .generator .Constants .GENERATED ;
19+ import static io .dinject .javalin .generator .Constants .GENERATED_8 ;
20+ import static io .dinject .javalin .generator .Constants .GENERATED_9 ;
1921import static io .dinject .javalin .generator .Constants .JAVALIN3_CONTEXT ;
2022import static io .dinject .javalin .generator .Constants .OPENAPIDEFINITION ;
2123
@@ -25,7 +27,7 @@ public class ProcessingContext {
2527 private final Filer filer ;
2628 private final Elements elements ;
2729 private final Types types ;
28- private final boolean generatedAvailable ;
30+ private final String generatedAnnotation ;
2931 private final boolean openApiAvailable ;
3032 private final boolean javalin3 ;
3133
@@ -36,10 +38,18 @@ public class ProcessingContext {
3638 this .filer = env .getFiler ();
3739 this .elements = env .getElementUtils ();
3840 this .types = env .getTypeUtils ();
39- this .generatedAvailable = isTypeAvailable (GENERATED );
4041 this .openApiAvailable = isTypeAvailable (OPENAPIDEFINITION );
4142 this .javalin3 = isTypeAvailable (JAVALIN3_CONTEXT );
4243 this .docContext = new DocContext (env , openApiAvailable );
44+ boolean jdk8 = env .getSourceVersion ().compareTo (SourceVersion .RELEASE_8 ) <= 0 ;
45+ this .generatedAnnotation = generatedAnnotation (jdk8 );
46+ }
47+
48+ private String generatedAnnotation (boolean jdk8 ) {
49+ if (jdk8 ) {
50+ return isTypeAvailable (GENERATED_8 ) ? GENERATED_8 : null ;
51+ }
52+ return isTypeAvailable (GENERATED_9 ) ? GENERATED_9 : null ;
4353 }
4454
4555 private boolean isTypeAvailable (String canonicalName ) {
@@ -51,7 +61,11 @@ TypeElement getTypeElement(String canonicalName) {
5161 }
5262
5363 boolean isGeneratedAvailable () {
54- return generatedAvailable ;
64+ return generatedAnnotation != null ;
65+ }
66+
67+ String getGeneratedAnnotation () {
68+ return generatedAnnotation ;
5569 }
5670
5771 boolean isOpenApiAvailable () {
0 commit comments