Skip to content

Instantly share code, notes, and snippets.

@cgrand cgrand/unbean.clj forked from jcromartie/unbean.clj
Created Jan 22, 2010

Embed
What would you like to do?
(defn unbean [m]
"Tries to recreate a simple JavaBean object from map m"
(let [obj (.newInstance (:class m))]
(doseq [#^java.beans.PropertyDescriptor pd (-> String java.beans.Introspector/getBeanInfo .getPropertyDescriptors)
:let [wm (.getWriteMethod pd) k (-> pd .getName keyword)] :when (and wm (contains? m k))]
(.invoke wm obj (to-array [(m k)])))
obj))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.