Created
November 27, 2017 21:20
-
-
Save fmnoise/61d31ca4e4d81b25b9f9cc2dfac79905 to your computer and use it in GitHub Desktop.
check if object can respond to method
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
(defn respond-to? | |
"Check if object can respond to method" | |
[obj method] | |
(boolean | |
(some->> obj | |
class | |
.getMethods | |
(filter #(= (.getName %) (name method))) | |
first | |
.getModifiers | |
java.lang.reflect.Modifier/isAbstract | |
not))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment