All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.tree.function.FunctionReferenceBuilder Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.tree.function;

import static org.snapscript.core.ModifierType.PUBLIC;
import static org.snapscript.core.Reserved.DEFAULT_PARAMETER;

import java.util.ArrayList;
import java.util.List;

import org.snapscript.core.Module;
import org.snapscript.core.function.Function;
import org.snapscript.core.function.Invocation;
import org.snapscript.core.function.InvocationFunction;
import org.snapscript.core.function.Parameter;
import org.snapscript.core.function.Signature;

public class FunctionReferenceBuilder {
   
   private final Parameter parameter;
   
   public FunctionReferenceBuilder() {
      this.parameter = new Parameter(DEFAULT_PARAMETER, null, true);
   }
   
   public Function create(Module module, Object value, String method) throws Exception {
      List parameters = new ArrayList();
      Signature signature = new Signature(parameters, module, null, true);
      Invocation invocation = new FunctionReferenceInvocation(module, value, method);
      
      parameters.add(parameter);
      
      return new InvocationFunction(signature, invocation, null, null, method, PUBLIC.mask);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy