fix: properly handle events with generics

This commit is contained in:
zaaarf 2024-12-04 10:37:58 +01:00
parent 22a60c7ed3
commit 24cee5fb48
No known key found for this signature in database
GPG key ID: C91CFF9E2262BBA1

View file

@ -243,11 +243,14 @@ public class GEBProcessor extends AbstractProcessor {
callListenersBuilder.addStatement("return true"); callListenersBuilder.addStatement("return true");
TypeMirror erasedEvent = this.processingEnv.getTypeUtils().erasure(event);
MethodSpec eventType = MethodSpec.methodBuilder("eventType") MethodSpec eventType = MethodSpec.methodBuilder("eventType")
.addModifiers(Modifier.PUBLIC) .addModifiers(Modifier.PUBLIC)
.addAnnotation(Override.class) .addAnnotation(Override.class)
.returns(ParameterizedTypeName.get(ClassName.get(Class.class), TypeName.get(event))) .addAnnotation(AnnotationSpec.builder(SuppressWarnings.class)
.addStatement("return $T.class", event) .addMember("value" , "{$S}", "rawtypes").build())
.returns(ParameterizedTypeName.get(Class.class))
.addStatement("return $T.class", erasedEvent)
.build(); .build();
String clazzName = String.format("%sDispatcher", eventClass.getSimpleName()); String clazzName = String.format("%sDispatcher", eventClass.getSimpleName());