<commit_before>package checkdep.value.depend;

import static java.util.stream.Collectors.*;

import java.util.Collection;
import java.util.Map;

import checkdep.util.ReadOnlyMap;
import com.google.common.collect.Maps;
import lombok.Delegate;
import lombok.NonNull;
import lombok.Value;

@Value(staticConstructor = "of")
public class Dependencies {

  @Delegate
  @NonNull
  private final ReadOnlyMap<PackageName, Dependency> delegate;

  public static Dependencies of(Collection<Dependency> collection) {
//    return toDependencies(collection.stream().collect(toMap(Dependency::getName, item -> item)));
    return toDependencies(Maps.uniqueIndex(collection, Dependency::getName));
  }

  private static Dependencies toDependencies(Map<PackageName, Dependency> map) {
    return of(ReadOnlyMap.copyOf(map));
  }

  public static Dependencies of(Map<PackageName, PackageNames> map) {
    return of(map.entrySet().stream()
        .map(item -> Dependency.of(item.getKey(), item.getValue()))
        .collect(toSet()));
  }

  public Dependencies find(PackageName name) {
    return of(values().stream()
        .filter(item -> name.matches(item.getName()))
        .collect(toSet()));
  }
}<commit_msg>refactoring<commit_after>package checkdep.value.depend;

import static java.util.stream.Collectors.*;

import java.util.Collection;
import java.util.Map;

import checkdep.util.ReadOnlyMap;
import com.google.common.collect.Maps;
import lombok.Delegate;
import lombok.NonNull;
import lombok.Value;

@Value(staticConstructor = "of")
public class Dependencies {

  public static Dependencies of(Collection<Dependency> collection) {
//    return toDependencies(collection.stream().collect(toMap(Dependency::getName, item -> item)));
    return toDependencies(Maps.uniqueIndex(collection, Dependency::getName));
  }

  private static Dependencies toDependencies(Map<PackageName, Dependency> map) {
    return of(ReadOnlyMap.copyOf(map));
  }

  public static Dependencies of(Map<PackageName, PackageNames> map) {
    return of(map.entrySet().stream()
        .map(item -> Dependency.of(item.getKey(), item.getValue()))
        .collect(toSet()));
  }

  @Delegate
  @NonNull
  private final ReadOnlyMap<PackageName, Dependency> delegate;

  public Dependencies find(PackageName name) {
    return of(values().stream()
        .filter(item -> name.matches(item.getName()))
        .collect(toSet()));
  }
}
{'fraction_non_alphanumeric': 0.13, 'fraction_numerical': 0.0, 'mean_word_length': 4.757793764988009, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3517329', 'n_tokens_mistral': 723, 'n_tokens_neox': 697, 'n_words': 144}