package org.smoothbuild.task.base;

import static org.smoothbuild.task.base.AlgorithmHashes.nativeCallAlgorithmHash;

import java.util.List;

import org.smoothbuild.lang.function.nativ.NativeFunction;
import org.smoothbuild.lang.type.Type;
import org.smoothbuild.lang.value.Value;
import org.smoothbuild.task.exec.ContainerImpl;

import com.google.common.hash.HashCode;

public class NativeCallAlgorithm implements Algorithm {
  private final NativeFunction function;

  public NativeCallAlgorithm(NativeFunction function) {
    this.function = function;
  }

  public HashCode hash() {
    return nativeCallAlgorithmHash(function);
  }

  public Type resultType() {
    return function.type();
  }

  public Output execute(Input input, ContainerImpl container) {
    Value result = function.invoke(container, calculateArguments(input));
    return new Output(result, container.messages());
  }

  private List<Value> calculateArguments(Input input) {
    return input.values();
  }
}

@@ -115,32 +115,8 @@
 h;%0A%0A
-import java.util.List;%0A%0A
 impo
@@ -783,32 +783,21 @@
 er, 
-calculateArguments(input
+input.values(
 ));%0A
@@ -856,95 +856,7 @@
 %0A  %7D
-%0A%0A  private List%3CValue%3E calculateArguments(Input input) %7B%0A    return input.values();%0A  %7D
 %0A%7D%0A

refactored NativeCallAlgorithm