2 * This code is generated in org.simantics.scl.runtime.generation.GenerateFunctions.
3 * Do not edit manually!
5 package org.simantics.scl.runtime.function;
\r
7 import java.util.Arrays;
\r
9 @SuppressWarnings("all")
\r
10 public abstract class FunctionImplN implements Function {
\r
13 public FunctionImplN(int arity) {
\r
15 throw new IllegalArgumentException();
\r
20 public Object apply(Object p0) {
\r
23 case 1: return doApply(p0);
\r
24 default: return new UnsaturatedFunction1(this, p0);
\r
26 } catch(ClassCastException e) {
\r
27 throw new CalledWithTooManyParameters();
\r
32 public Object apply(Object p0, Object p1) {
\r
35 case 1: return ((Function)doApply(p0)).apply(p1);
\r
36 case 2: return doApply(p0, p1);
\r
37 default: return new UnsaturatedFunction2(this, p0, p1);
\r
39 } catch(ClassCastException e) {
\r
40 throw new CalledWithTooManyParameters();
\r
45 public Object apply(Object p0, Object p1, Object p2) {
\r
48 case 1: return ((Function)doApply(p0)).apply(p1, p2);
\r
49 case 2: return ((Function)doApply(p0, p1)).apply(p2);
\r
50 case 3: return doApply(p0, p1, p2);
\r
51 default: return new UnsaturatedFunction3(this, p0, p1, p2);
\r
53 } catch(ClassCastException e) {
\r
54 throw new CalledWithTooManyParameters();
\r
59 public Object apply(Object p0, Object p1, Object p2, Object p3) {
\r
62 case 1: return ((Function)doApply(p0)).apply(p1, p2, p3);
\r
63 case 2: return ((Function)doApply(p0, p1)).apply(p2, p3);
\r
64 case 3: return ((Function)doApply(p0, p1, p2)).apply(p3);
\r
65 case 4: return doApply(p0, p1, p2, p3);
\r
66 default: return new UnsaturatedFunction4(this, p0, p1, p2, p3);
\r
68 } catch(ClassCastException e) {
\r
69 throw new CalledWithTooManyParameters();
\r
74 public Object apply(Object p0, Object p1, Object p2, Object p3, Object p4) {
\r
77 case 1: return ((Function)doApply(p0)).apply(p1, p2, p3, p4);
\r
78 case 2: return ((Function)doApply(p0, p1)).apply(p2, p3, p4);
\r
79 case 3: return ((Function)doApply(p0, p1, p2)).apply(p3, p4);
\r
80 case 4: return ((Function)doApply(p0, p1, p2, p3)).apply(p4);
\r
81 case 5: return doApply(p0, p1, p2, p3, p4);
\r
82 default: return new UnsaturatedFunction5(this, p0, p1, p2, p3, p4);
\r
84 } catch(ClassCastException e) {
\r
85 throw new CalledWithTooManyParameters();
\r
90 public Object apply(Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) {
\r
93 case 1: return ((Function)doApply(p0)).apply(p1, p2, p3, p4, p5);
\r
94 case 2: return ((Function)doApply(p0, p1)).apply(p2, p3, p4, p5);
\r
95 case 3: return ((Function)doApply(p0, p1, p2)).apply(p3, p4, p5);
\r
96 case 4: return ((Function)doApply(p0, p1, p2, p3)).apply(p4, p5);
\r
97 case 5: return ((Function)doApply(p0, p1, p2, p3, p4)).apply(p5);
\r
98 case 6: return doApply(p0, p1, p2, p3, p4, p5);
\r
99 default: return new UnsaturatedFunction6(this, p0, p1, p2, p3, p4, p5);
\r
101 } catch(ClassCastException e) {
\r
102 throw new CalledWithTooManyParameters();
\r
107 public Object apply(Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) {
\r
110 case 1: return ((Function)doApply(p0)).apply(p1, p2, p3, p4, p5, p6);
\r
111 case 2: return ((Function)doApply(p0, p1)).apply(p2, p3, p4, p5, p6);
\r
112 case 3: return ((Function)doApply(p0, p1, p2)).apply(p3, p4, p5, p6);
\r
113 case 4: return ((Function)doApply(p0, p1, p2, p3)).apply(p4, p5, p6);
\r
114 case 5: return ((Function)doApply(p0, p1, p2, p3, p4)).apply(p5, p6);
\r
115 case 6: return ((Function)doApply(p0, p1, p2, p3, p4, p5)).apply(p6);
\r
116 case 7: return doApply(p0, p1, p2, p3, p4, p5, p6);
\r
117 default: return new UnsaturatedFunction7(this, p0, p1, p2, p3, p4, p5, p6);
\r
119 } catch(ClassCastException e) {
\r
120 throw new CalledWithTooManyParameters();
\r
125 public Object apply(Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) {
\r
128 case 1: return ((Function)doApply(p0)).apply(p1, p2, p3, p4, p5, p6, p7);
\r
129 case 2: return ((Function)doApply(p0, p1)).apply(p2, p3, p4, p5, p6, p7);
\r
130 case 3: return ((Function)doApply(p0, p1, p2)).apply(p3, p4, p5, p6, p7);
\r
131 case 4: return ((Function)doApply(p0, p1, p2, p3)).apply(p4, p5, p6, p7);
\r
132 case 5: return ((Function)doApply(p0, p1, p2, p3, p4)).apply(p5, p6, p7);
\r
133 case 6: return ((Function)doApply(p0, p1, p2, p3, p4, p5)).apply(p6, p7);
\r
134 case 7: return ((Function)doApply(p0, p1, p2, p3, p4, p5, p6)).apply(p7);
\r
135 case 8: return doApply(p0, p1, p2, p3, p4, p5, p6, p7);
\r
136 default: return new UnsaturatedFunction8(this, p0, p1, p2, p3, p4, p5, p6, p7);
\r
138 } catch(ClassCastException e) {
\r
139 throw new CalledWithTooManyParameters();
\r
143 public abstract Object doApply(Object ... ps);
\r
146 public Object applyArray(Object ... ps) {
\r
147 if(ps.length == arity)
\r
148 return doApply(ps);
\r
149 else if(ps.length < arity)
\r
150 return new UnsaturatedFunctionN(this, ps);
\r
151 else /* ps.length > arity */ {
\r
153 return ((Function)doApply(Arrays.copyOf(ps, arity))).applyArray(Arrays.copyOfRange(ps, arity, ps.length));
\r
154 } catch(ClassCastException e) {
\r
155 throw new CalledWithTooManyParameters();
\r