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