Remove EventListener and IEvent marker interfaces

This allows Event Bus to interface with existing classes without
modification.
This commit is contained in:
2021-02-15 14:43:34 +01:00
parent cd2e7ad023
commit 002180ed3b
10 changed files with 33 additions and 82 deletions

View File

@ -34,8 +34,7 @@ public class EventProcessor extends AbstractProcessor {
private void processRound(Set<ExecutableElement> eventHandlers) {
for (ExecutableElement eventHandler : eventHandlers) {
TypeElement eventListener = (TypeElement) eventHandler.getEnclosingElement();
Event eventAnnotation = eventHandler.getAnnotation(Event.class);
Event eventAnnotation = eventHandler.getAnnotation(Event.class);
// Determine how the event type is defined
boolean useParameter;
@ -68,11 +67,6 @@ public class EventProcessor extends AbstractProcessor {
var paramElement = eventHandler.getParameters().get(0);
var paramType = paramElement.asType();
// Check for valid event type
if (useParameter && !processingEnv.getTypeUtils().isAssignable(paramType,
getTypeMirror(IEvent.class)))
error(paramElement, "Parameter must implement IEvent");
// Check for handlers for abstract types that aren't polymorphic
if (eventHandler.getAnnotation(Polymorphic.class) == null
&& paramType.getKind() == TypeKind.DECLARED) {
@ -82,11 +76,6 @@ public class EventProcessor extends AbstractProcessor {
warning(paramElement,
"Parameter should be instantiable or handler should use @Polymorphic");
}
// Check listener for interface implementation
if (!eventListener.getInterfaces().contains(getTypeMirror(EventListener.class)))
warning(eventHandler.getEnclosingElement(),
"Class should implement EventListener interface");
}
}