Created
April 23, 2010 02:50
-
-
Save michalmarczyk/376105 to your computer and use it in GitHub Desktop.
update a Java bean given a Clojure (keywordised property name -> value) map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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