<commit_before>package org.smoothbuild.parse.arg;

import static com.google.common.base.Preconditions.checkArgument;
import static org.smoothbuild.lang.type.Types.allTypes;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.smoothbuild.lang.function.base.ParameterInfo;
import org.smoothbuild.lang.type.Type;
import org.smoothbuild.lang.type.TypeSystem;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

public class ParametersPool {
  private final TypeSystem typeSystem;
  private final ImmutableMap<Type, TypedParametersPool> typePools;
  private final Map<Type, Set<ParameterInfo>> optionalParametersMap;
  private final Map<Type, Set<ParameterInfo>> requiredParametersMap;

  public ParametersPool(TypeSystem typeSystem, Collection<? extends ParameterInfo> optional,
      Collection<? extends ParameterInfo> required) {
    this.typeSystem = typeSystem;
    this.optionalParametersMap = createParametersMap(optional);
    this.requiredParametersMap = createParametersMap(required);
    this.typePools = createTypePools(optionalParametersMap, requiredParametersMap);
  }

  public ParameterInfo take(ParameterInfo parameter) {
    boolean hasBeenRemoved = remove(parameter);
    checkArgument(hasBeenRemoved);
    return parameter;
  }

  private boolean remove(ParameterInfo parameter) {<commit_msg>change ParametersPool constructor to take Sets instead of Collections<commit_after>package org.smoothbuild.parse.arg;

import static com.google.common.base.Preconditions.checkArgument;
import static org.smoothbuild.lang.type.Types.allTypes;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.smoothbuild.lang.function.base.ParameterInfo;
import org.smoothbuild.lang.type.Type;
import org.smoothbuild.lang.type.TypeSystem;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

public class ParametersPool {
  private final TypeSystem typeSystem;
  private final ImmutableMap<Type, TypedParametersPool> typePools;
  private final Map<Type, Set<ParameterInfo>> optionalParametersMap;
  private final Map<Type, Set<ParameterInfo>> requiredParametersMap;

  public ParametersPool(TypeSystem typeSystem, Set<? extends ParameterInfo> optional,
      Set<? extends ParameterInfo> required) {
    this.typeSystem = typeSystem;
    this.optionalParametersMap = createParametersMap(optional);
    this.requiredParametersMap = createParametersMap(required);
    this.typePools = createTypePools(optionalParametersMap, requiredParametersMap);
  }

  public ParameterInfo take(ParameterInfo parameter) {
    boolean hasBeenRemoved = remove(parameter);
    checkArgument(hasBeenRemoved);
    return parameter;
  }

  private boolean remove(ParameterInfo parameter) {
{'fraction_non_alphanumeric': 0.08694236405079779, 'fraction_numerical': 0.0, 'mean_word_length': 6.062068965517241, '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': '4890697', 'n_tokens_mistral': 836, 'n_tokens_neox': 821, 'n_words': 182}