<commit_before>package org.pitest.classpath;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.pitest.functional.FCollection;
import java.util.Optional;

public class CompoundClassPathRoot implements ClassPathRoot,
    Iterable<ClassPathRoot> {

  private final List<ClassPathRoot> roots = new ArrayList<>();

  public CompoundClassPathRoot(final List<ClassPathRoot> roots) {
    this.roots.addAll(wrapToAvoidIOOperations(roots));
  }

  @Override
  public InputStream getData(final String name) throws IOException {
    for (final ClassPathRoot each : this.roots) {
      final InputStream is = each.getData(name);
      if (is != null) {
        return is;
      }
    }
    return null;
  }

  @Override
  public Collection<String> classNames() {
    final List<String> arrayList = new ArrayList<>();
    for (final ClassPathRoot root : this.roots) {
      arrayList.addAll(root.classNames());
    }
    return arrayList;
  }

  @Override
  public URL getResource(String name) throws MalformedURLException {
    try {
      return findRootForResource(name);
    } catch (final IOException exception) {
      return null;
    }
  }

  private URL findRootForResource(final String name) throws IOException {
    for (final ClassPathRoot root : this.roots) {
      final URL u = root.getResource(name);
      if (u != null) {
        return u;
      }
    }
    return null;
  }

  @Override
  public Optional<String> cacheLocation() {
    StringBuilder classpath = new StringBuilder();
    for (final ClassPathRoot each : this.roots) {
      final Optional<String> additional = each.cacheLocation();
      if (additional.isPresent()) {
        classpath = classpath.append(File.pathSeparator + additional.get());
      }
    }

    return Optional.ofNullable(classpath.toString());
  }

  @Override
  public Iterator<ClassPathRoot> iterator() {
    return this.roots.iterator();
  }

  private  static List<ClassPathRoot> wrapToAvoidIOOperations(<commit_msg>Do not include the current directory to the minion class path<commit_after>package org.pitest.classpath;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.pitest.functional.FCollection;
import java.util.Optional;

public class CompoundClassPathRoot implements ClassPathRoot,
    Iterable<ClassPathRoot> {

  private final List<ClassPathRoot> roots = new ArrayList<>();

  public CompoundClassPathRoot(final List<ClassPathRoot> roots) {
    this.roots.addAll(wrapToAvoidIOOperations(roots));
  }

  @Override
  public InputStream getData(final String name) throws IOException {
    for (final ClassPathRoot each : this.roots) {
      final InputStream is = each.getData(name);
      if (is != null) {
        return is;
      }
    }
    return null;
  }

  @Override
  public Collection<String> classNames() {
    final List<String> arrayList = new ArrayList<>();
    for (final ClassPathRoot root : this.roots) {
      arrayList.addAll(root.classNames());
    }
    return arrayList;
  }

  @Override
  public URL getResource(String name) throws MalformedURLException {
    try {
      return findRootForResource(name);
    } catch (final IOException exception) {
      return null;
    }
  }

  private URL findRootForResource(final String name) throws IOException {
    for (final ClassPathRoot root : this.roots) {
      final URL u = root.getResource(name);
      if (u != null) {
        return u;
      }
    }
    return null;
  }

  @Override
  public Optional<String> cacheLocation() {
    StringBuilder classpath = new StringBuilder();
    for (final ClassPathRoot each : this.roots) {
      final Optional<String> additional = each.cacheLocation();
      if (additional.isPresent()) {
        if (classpath.length() != 0) {
          classpath.append(File.pathSeparator);
        }
        classpath.append(additional.get());
      }
    }

    return Optional.ofNullable(classpath.toString());
  }

  @Override
  public Iterator<ClassPathRoot> iterator() {
    return this.roots.iterator();
  }

  private  static List<ClassPathRoot> wrapToAvoidIOOperations(
{'fraction_non_alphanumeric': 0.10103510351035104, 'fraction_numerical': 0.000225022502250225, 'mean_word_length': 3.46285140562249, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '1116524', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1268, 'n_words': 321}