--- /dev/null
+package org.simantics.scl.reflection.functions;\r
+\r
+import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.Method;\r
+\r
+import org.simantics.scl.runtime.function.FunctionImplN;\r
+\r
+public class ClassMethodFunction extends FunctionImplN {\r
+ Method method;\r
+\r
+ public ClassMethodFunction(Method method) {\r
+ super(method.getParameterTypes().length);\r
+ this.method = method;\r
+ }\r
+ \r
+ public Method getMethod() {\r
+ return method;\r
+ }\r
+\r
+ @Override\r
+ public Object doApply(Object... ps) {\r
+ try {\r
+ return method.invoke(null, ps);\r
+ } catch (IllegalArgumentException e) {\r
+ throw new RuntimeException(e);\r
+ } catch (IllegalAccessException e) {\r
+ throw new RuntimeException(e);\r
+ } catch (InvocationTargetException e) {\r
+ //e.printStackTrace();\r
+ throw new RuntimeException(e);\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return method.getName();\r
+ }\r
+}\r