Last active
October 9, 2015 14:18
-
-
Save icholy/3521440 to your computer and use it in GitHub Desktop.
search an objects or classes methods
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 search-method [obj search-str] | |
"take an object and a search string and return a list of | |
of methods on that object that match the search string" | |
(let [clazz (if (= (.getClass obj) java.lang.Class) | |
obj | |
(.getClass obj)) | |
re (re-pattern (str "(?i)" search-str))] | |
(for [method (seq (.getMethods clazz)) | |
:let [method-name (.getName method)] | |
:when (re-find re method-name)] | |
method-name))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment