-package org.simantics.scl.reflection.functions;\r
-\r
-import java.lang.reflect.Constructor;\r
-import java.lang.reflect.InvocationTargetException;\r
-\r
-import org.simantics.scl.runtime.function.FunctionImplN;\r
-\r
-public class ConstructorFunction extends FunctionImplN {\r
- Constructor<?> constructor;\r
-\r
- public ConstructorFunction(Constructor<?> constructor) {\r
- super(constructor.getParameterTypes().length);\r
- this.constructor = constructor;\r
- }\r
- \r
- public Constructor<?> getConstructor() {\r
- return constructor;\r
- }\r
-\r
- @Override\r
- public Object doApply(Object... ps) {\r
- try {\r
- return constructor.newInstance(ps);\r
- } catch (InstantiationException e) {\r
- throw new RuntimeException(e);\r
- } catch (IllegalArgumentException e) {\r
- throw new RuntimeException(e);\r
- } catch (IllegalAccessException e) {\r
- throw new RuntimeException(e);\r
- } catch (InvocationTargetException e) {\r
- throw new RuntimeException(e.getCause());\r
- }\r
- }\r
- \r
- @Override\r
- public String toString() {\r
- return constructor.getName();\r
- }\r
-}\r
+package org.simantics.scl.reflection.functions;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.simantics.scl.runtime.function.FunctionImplN;
+
+public class ConstructorFunction extends FunctionImplN {
+ Constructor<?> constructor;
+
+ public ConstructorFunction(Constructor<?> constructor) {
+ super(constructor.getParameterTypes().length);
+ this.constructor = constructor;
+ }
+
+ public Constructor<?> getConstructor() {
+ return constructor;
+ }
+
+ @Override
+ public Object doApply(Object... ps) {
+ try {
+ return constructor.newInstance(ps);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e.getCause());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return constructor.getName();
+ }
+}