]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.commands/src/org/simantics/scl/commands/internal/checker/FunctionCheckItem.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.commands / src / org / simantics / scl / commands / internal / checker / FunctionCheckItem.java
1 package org.simantics.scl.commands.internal.checker;
2
3 import java.util.List;
4
5 import org.simantics.scl.compiler.types.Type;
6 import org.simantics.scl.runtime.function.Function;
7
8 public class FunctionCheckItem implements CheckItem {
9
10     Type parameterType;
11     CheckItem next;
12     
13     public FunctionCheckItem(Type parameterType, CheckItem next) {
14         this.parameterType = parameterType;
15         this.next = next;
16     }
17
18     @SuppressWarnings({ "unchecked", "rawtypes" })
19     @Override
20     public boolean check(Object check, Object[] parameters, int pos) {
21         if(pos == parameters.length)
22             return true;
23         Object nextCheck = ((Function)check).apply(parameters[pos]);
24         return next.check(nextCheck, parameters, pos+1);
25     }
26
27     @Override
28     public void collectParameterTypes(List<Type> types) {
29         types.add(parameterType);
30         next.collectParameterTypes(types);
31     }
32
33 }