// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
//   if (predicate.test(value)) {
//     return value;
//   } else {
//     throw new IllegalArgumentException();
//   }
// }
// 
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
//   if (reference != null) {
//     return reference;
//   } else {
//     throw new NullPointerException();
//   }
// }
// 
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
//   if (!expression) {
//     throw new IllegalStateException();
//   }
// }
// 
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
//   propagateIfPossible(checkNotNull(throwable));
//   throw new RuntimeException(throwable);
// }
// 
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
//   return new UrlByteSource(checkNotNull(url));
// }
// 
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
//   return asByteSource(url)
//       .asCharSource(charset);
// }


import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;
     * @param classLoader
     * @return
     * @throws IllegalArgumentException
     */
    public Builder addClassLoader(URLClassLoader classLoader) {
      checkNotNull(classLoader, "classLoader must not be null");
      stream(classLoader.getURLs())
          .filter((url) -> supportedProtocols.contains(url.getProtocol()))
          .findFirst()
          .orElseThrow(() -> new IllegalArgumentException("No URL in URLClassLoader are usable"));
      classLoaders.add(classLoader);
      return this;
    }

    /**
     *
     * @param jarSource
     * @return throws IllegalArgumentException
     */
    public Builder addJar(Path jarSource) {
      checkNotNull(jarSource);
      try {
        new JarFile(jarSource.toFile()); // Check that it's a valid jar file.
        URL url = jarSource.toUri().toURL();
        try {
          url = new URL("jar", "", -1, url.toString() + "!/");
        } catch (MalformedURLException unused) {
        }
        classLoaders.add(new URLClassLoader(new URL[]{url}, null));
      } catch (IOException unused) {
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
//   if (predicate.test(value)) {
//     return value;
//   } else {
//     throw new IllegalArgumentException();
//   }
// }
// 
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
//   if (reference != null) {
//     return reference;
//   } else {
//     throw new NullPointerException();
//   }
// }
// 
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
//   if (!expression) {
//     throw new IllegalStateException();
//   }
// }
// 
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
//   propagateIfPossible(checkNotNull(throwable));
//   throw new RuntimeException(throwable);
// }
// 
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
//   return new UrlByteSource(checkNotNull(url));
// }
// 
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
//   return asByteSource(url)
//       .asCharSource(charset);
// }


// Path: src/main/java/be/fror/common/resource/ResourceLocator.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;

     * @param classLoader
     * @return
     * @throws IllegalArgumentException
     */
    public Builder addClassLoader(URLClassLoader classLoader) {
      checkNotNull(classLoader, "classLoader must not be null");
      stream(classLoader.getURLs())
          .filter((url) -> supportedProtocols.contains(url.getProtocol()))
          .findFirst()
          .orElseThrow(() -> new IllegalArgumentException("No URL in URLClassLoader are usable"));
      classLoaders.add(classLoader);
      return this;
    }

    /**
     *
     * @param jarSource
     * @return throws IllegalArgumentException
     */
    public Builder addJar(Path jarSource) {
      checkNotNull(jarSource);
      try {
        new JarFile(jarSource.toFile()); // Check that it's a valid jar file.
        URL url = jarSource.toUri().toURL();
        try {
          url = new URL("jar", "", -1, url.toString() + "!/");
        } catch (MalformedURLException unused) {
        }
        classLoaders.add(new URLClassLoader(new URL[]{url}, null));
      } catch (IOException unused) {
        checkArgument(false, "jarSource doesn't refer to a valid jar file");