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

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

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

import org.snapscript.core.type.index.ScopeType;
import org.snapscript.core.variable.Value;

public class FunctionHandleAligner {
   
   private final Value value;
   private final boolean constructor;

   public FunctionHandleAligner(Value value, boolean constructor){
      this.constructor = constructor;
      this.value = value;
   }
   
   public Object[] align(Object... list) throws Exception {      
      if(constructor) {
         Object object = value.getValue();
         
         if(ScopeType.class.isInstance(object)) { // inject type parameter
            Object[] arguments = new Object[list.length +1];
         
            for(int i = 0; i < list.length; i++) {
               arguments[i + 1] = list[i];
            }
            arguments[0] = object;
            return arguments;
         }
      }
      return list;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy