Skip to content

Instantly share code, notes, and snippets.

@icholy
Last active October 9, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icholy/3521440 to your computer and use it in GitHub Desktop.
Save icholy/3521440 to your computer and use it in GitHub Desktop.
search an objects or classes methods
(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