package com.github.blackrush.acara;

import org.fungsi.concurrent.Future;
import org.fungsi.concurrent.Worker;

import java.lang.reflect.Method;

public final class JavaListener extends Listener {
    final EventMetadata signature;
    final Object state;
    final Method behavior;

    public JavaListener(EventMetadata signature, Object state, Method behavior) {
        this.signature = signature;
        this.state = state;
        this.behavior = behavior;
    }

    @Override
    public EventMetadata getHandledEvent() {
        return signature;
    }

    @Override
    public Future<Object> dispatch(Object event, Worker worker) {
        return worker.submit(() -> behavior.invoke(state, event));
    }
}

@@ -146,22 +146,16 @@
 %0Apublic 
-final 
 class Ja
@@ -664,16 +664,168 @@
 it(() -%3E
+ this.invoke(state, behavior, event));%0A    %7D%0A%0A    protected Object invoke(Object state, Method behavior, Object event) throws Throwable %7B%0A        return
  behavio
@@ -838,27 +838,26 @@
 ke(state, event)
-)
 ;%0A    %7D%0A%7D%0A

Make JavaListener non-final to quickly define new listeners