Skip to content

Instantly share code, notes, and snippets.

@michalmarczyk
Created April 23, 2010 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michalmarczyk/376105 to your computer and use it in GitHub Desktop.
Save michalmarczyk/376105 to your computer and use it in GitHub Desktop.
update a Java bean given a Clojure (keywordised property name -> value) map
(defmacro update-bean
[obj props-map]
`(let [obj# ~obj
props-map# ~props-map
dots# (map (fn [[k# v#]]
`(. ~(->> k# as-str camelize upcase (str "set") symbol) ~v#))
props-map#)
doto# `(doto ~obj# ~@dots#)]
(eval doto#)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment