I am trying to translate some Java code directly into Clojure on a raspberry pi. I am stuck at implementing an interface in a method call - addListener.
I have tried using reify, proxy, and deftype. With reify I have tried providing as many hints to the compiler as possible.
This is the original Java code:
myButton.addListener(new GpioPinListenerDigital() {
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = " + event.getState());
}
});
And this is my translated Clojure code:
(.addListener myButton
(reify GpioPinListenerDigital
(^void handleGpioPinDigitalStateChangeEvent [this ^GpioPinDigitalStateChangeEvent event]
(println (str " --> GPIO PIN STATE CHANGE: " (.getPin event) " = " (.getState event))))))
I always end up with the same error:
IllegalArgumentException No matching method found: addListener for class com.pi4j.io.gpio.impl.GpioPinImpl clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:79)