]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/functions/ClassMethodFunction3.java
Revert "Prime SCL BindingRegistry to shave ~0.5s from startup"
[simantics/platform.git] / bundles / org.simantics.scl.reflection / src / org / simantics / scl / reflection / functions / ClassMethodFunction3.java
1 package org.simantics.scl.reflection.functions;
2
3 import java.lang.reflect.InvocationTargetException;
4 import java.lang.reflect.Method;
5
6 import org.simantics.scl.runtime.function.FunctionImpl3;
7
8 public class ClassMethodFunction3 extends FunctionImpl3 {
9     Method method;
10
11     public ClassMethodFunction3(Method method) {
12         this.method = method;
13     }
14     
15     public Method getMethod() {
16         return method;
17     }
18
19     @Override
20     public Object apply(Object p0, Object p1, Object p2) {
21         try {
22             return method.invoke(null, p0, p1, p2);
23         } catch (IllegalArgumentException e) {
24             throw new RuntimeException(e);
25         } catch (IllegalAccessException e) {
26             throw new RuntimeException(e);
27         } catch (InvocationTargetException e) {
28             throw new RuntimeException(e.getCause());
29         }
30     }
31     
32     @Override
33     public String toString() {
34         return method.getName();
35     }
36 }