Reputation: 337
Is it possible to pass a type parameter into a generic interface that is being implemented by deftype? I'm trying to work with a framework that relies heaviliy on type parameters, and got stuck with apparent inability to do so with pure Clojure. I could fall back to pure Java, but it makes code and build configuration more cumbersome for other reasons, so ideally I would like to keep it pure.
Java equvalent of the code I'm looking to write is like the following:
public class BlahBlahSerializer implements SerializationCustomSerializer<BlahBlah, BlahBlahProxy> {
/* implementation here */
}
I'm looking for a way to write something like this in Clojure:
(deftype BlahBlahSerializer []
^{:generic-type-parameters [BlahBlah BlahBlahProxy]} SerializationCustomSerializer
/* implementation here */)
Is it possible at all?
Upvotes: 1
Views: 264
Reputation: 1904
I ran into this issue when writing a clojure library for Apache Beam, where Beam used reflection of the generics for various purposes, and was unable to find a way around it. My conclusion was that there's no way to get this information into the emitted class using clojure, though that's not definitive. My solution was to write small classes that defined those things in Java but whose method implementations immediately delegated to Clojure code.
https://github.com/zendesk/clj-headlights
Upvotes: 0