I have a java interface that just emits events, and I'm trying to implement it in Clojure. The Java interface is like this (plenty of other methods in reality):
public interface EWrapper {
void accountSummary(int reqId, String account, String tag, String value, String currency);
void accountSummaryEnd(int reqId);
}
And my Clojure code looks like:
(defn create
"Creates a wrapper calling a single function (cb) with maps that all have a :type to indicate
what type of messages was received, and event parameters
"
[cb]
(reify
EWrapper
(accountSummary [this reqId account tag value currency]
(dispatch-message cb {:type :account-summary :request-id reqId :account account :tag tag :value value :currency currency}))
(accountSummaryEnd [this reqId]
(dispatch-message cb {:type :account-summary-end :request-id reqId}))
))
I have about 75 functions to "implement" and all my implementation does is dispatching a map looking like {:type calling-function-name-kebab-case :parameter-one-kebab-case parameter-one-value :parameter-two-kebab-case parameter-two-value}
etc. It seems ripe for another macro - which would also be safer as if the underlying interface gets updated with more functions, so will my implementation.
Is that possible? How do I even get started? My ideal scenario would be to read the .java code directly, but alternatively I can manually paste the Java code into a map structure? Thank you,