I am using a Java class that represents a sequence of results (somewhat like a Clojure vector).
I would like to use this class with the typical Clojure sequence functions (i.e. I want to have the class behave as if it supported the sequence abstraction) however I can't change the class so am unable to make it implement clojure.lang.Seqable or similar. Also, annoyingly, the class does not implement java.util.Collection or java.lang.Iterable.
I can see a few options:
- Use
iterator-seqon the object's (existing) iterator. - Wrap the object in another class that implements
java.util.Collection/clojure.lang.Sequable - Create a function that builds a Clojure vector or sequence by querying the Object
Are there any other options? What is the best approach?
iterator-seqseems to be fine, internally it does the same thing as your second point about wrapping the object - Ankur