X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.reflection%2Fsrc%2Forg%2Fsimantics%2Fscl%2Freflection%2Ffunctions%2FClassMethodFunction3.java;fp=bundles%2Forg.simantics.scl.reflection%2Fsrc%2Forg%2Fsimantics%2Fscl%2Freflection%2Ffunctions%2FClassMethodFunction3.java;h=17dafa3ec964dee2ba07a227c7972323192fd6be;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/functions/ClassMethodFunction3.java b/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/functions/ClassMethodFunction3.java new file mode 100644 index 000000000..17dafa3ec --- /dev/null +++ b/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/functions/ClassMethodFunction3.java @@ -0,0 +1,38 @@ +package org.simantics.scl.reflection.functions; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.simantics.scl.runtime.function.FunctionImpl3; +import org.simantics.scl.runtime.function.FunctionImplN; + +public class ClassMethodFunction3 extends FunctionImpl3 { + Method method; + + public ClassMethodFunction3(Method method) { + this.method = method; + } + + public Method getMethod() { + return method; + } + + @Override + public Object apply(Object p0, Object p1, Object p2) { + try { + return method.invoke(null, p0, p1, p2); + } catch (IllegalArgumentException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + //e.printStackTrace(); + throw new RuntimeException(e); + } + } + + @Override + public String toString() { + return method.getName(); + } +}