Created
February 16, 2019 03:25
-
-
Save cassc/fb35446d5b5c1d323f2aed16ce1137dc to your computer and use it in GitHub Desktop.
Call java no-arg getter in clojure
This file contains 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
(defn invoke-get [obj ^String field] | |
(.. obj | |
(getClass) | |
(getDeclaredMethod (str "get" (clojure.string/capitalize field)) (into-array Class nil)) | |
(invoke obj (into-array Class nil)))) | |
(invoke-get (java.util.Date.) "time") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment