<commit_before>package org.smoothbuild.lang.function.nativ;

import static java.lang.reflect.Proxy.newProxyInstance;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;

import org.smoothbuild.lang.base.Value;

import com.google.common.collect.ImmutableMap;

public class ArgumentsCreator {
  private final Class<?> paramsInterface;

  public ArgumentsCreator(Class<?> paramsInterface) {
    this.paramsInterface = paramsInterface;
  }

  public Object create(Map<String, Value> arguments) {
    ClassLoader classLoader = paramsInterface.getClassLoader();
    Class<?>[] args = new Class<?>[] { paramsInterface };
    InvocationHandler invocationHandler = new MapInvocationHandler(arguments);

    return newProxyInstance(classLoader, args, invocationHandler);
  }

  private final class MapInvocationHandler implements InvocationHandler {
    private final ImmutableMap<String, Value> arguments;

    private MapInvocationHandler(Map<String, Value> arguments) {
      this.arguments = ImmutableMap.copyOf(arguments);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
      return arguments.get(method.getName());
    }
  }
}
<commit_msg>cleaned up variable names in ArgumentsCreator<commit_after>package org.smoothbuild.lang.function.nativ;

import static java.lang.reflect.Proxy.newProxyInstance;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Map;

import org.smoothbuild.lang.base.Value;

import com.google.common.collect.ImmutableMap;

public class ArgumentsCreator {
  private final Class<?> parametersInterface;

  public ArgumentsCreator(Class<?> parametersInterface) {
    this.parametersInterface = parametersInterface;
  }

  public Object create(Map<String, Value> arguments) {
    ClassLoader classLoader = parametersInterface.getClassLoader();
    Class<?>[] args = new Class<?>[] {parametersInterface};
    InvocationHandler invocationHandler = new MapInvocationHandler(arguments);

    return newProxyInstance(classLoader, args, invocationHandler);
  }

  private final class MapInvocationHandler implements InvocationHandler {
    private final ImmutableMap<String, Value> arguments;

    private MapInvocationHandler(Map<String, Value> arguments) {
      this.arguments = ImmutableMap.copyOf(arguments);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
      return arguments.get(method.getName());
    }
  }
}

{'fraction_non_alphanumeric': 0.09433962264150944, 'fraction_numerical': 0.0, 'mean_word_length': 5.059523809523809, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7591468', 'n_tokens_mistral': 682, 'n_tokens_neox': 671, 'n_words': 161}