How can I pass a static method as an argument?
If you mean as an argument to a Clojure function, wrap it in a function like #(UUID/randomUUID)
As an argument to a java static method 🙂
I would hesitantly suggest using a lambda expression, but I've not used them in Java 😄
That seems right
In Java or in Clojure?
In Java, as a Class::method method reference
From Clojure right now, you’ll need to reify a Java functional interface (but this is an area of active work)
This is a pure java question What's the type of that argument? How do I invoke the method I passed as an argument?
it depends on the method
it's being treated as some kind of functional interface, so a method that is Object f(Object) could be typed as a java.util.function.Function for example
clojure.lang.Util/equiv and clojure.lang.Util/equals 🙂
BiPredicate?
what are you passing it to?
BiPredicate is probably the best match there
I have a couple of static methods whose only difference is which static method they're calling, equiv/equals
You can make your own interface
interface EqualityMethod {
static EqualityMethod EQUIV = clojure.lang.Util::equiv;
static EqualityMethod EQUALS = clojure.lang.Util::equals;
boolean areEquivalent(Object a, Object b);
}