Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Sep 30, 2024
1 parent 521ff7e commit a632e42
Show file tree
Hide file tree
Showing 2 changed files with 722 additions and 631 deletions.
32 changes: 32 additions & 0 deletions reflector/src-java8/sci/impl/FISupport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package sci.impl;

import clojure.lang.RT;
import clojure.lang.IPersistentSet;
import java.util.concurrent.Callable;
import java.lang.reflect.Modifier;
import java.util.Comparator;

class FISupport {
private static final IPersistentSet AFN_FIS = RT.set(Callable.class, Runnable.class, Comparator.class);
private static final IPersistentSet OBJECT_METHODS = RT.set("equals", "toString", "hashCode");

// Return FI method if:
// 1) Target is a functional interface and not already implemented by AFn
// 2) Target method matches one of our fn invoker methods (0 <= arity <= 10)
protected static java.lang.reflect.Method maybeFIMethod(Class target) {
if (target != null && target.isAnnotationPresent(FunctionalInterface.class)
&& !AFN_FIS.contains(target)) {

java.lang.reflect.Method[] methods = target.getMethods();
for (java.lang.reflect.Method method : methods) {
if (method.getParameterCount() >= 0 && method.getParameterCount() <= 10
&& Modifier.isAbstract(method.getModifiers())
&& !OBJECT_METHODS.contains(method.getName()))
return method;
}
}
return null;
}
}


Loading

0 comments on commit a632e42

Please sign in to comment.