Skip to content

Instantly share code, notes, and snippets.

@pingles
Created March 30, 2011 20:55
Show Gist options
  • Save pingles/895284 to your computer and use it in GitHub Desktop.
Save pingles/895284 to your computer and use it in GitHub Desktop.
Protocols work quite nicely for adapting Java types to Clojure data structures
(defprotocol ToClojure
(to-clojure [x]))
(extend-protocol ToClojure
List (to-clojure [xs] (map to-clojure xs))
RecommendedItem (to-clojure [x] {:item (.getItemID x)
:value (.getValue x)}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment