public ClassFinder add(Collection<File> files) {
    for (File file : files)
      add(file);

    return this;
  }

  /**
   * Clear the finder's notion of where to search.
   */
  public void clear() {
    placesToSearch.clear();
  }

  public ClassFinder setErrorIfResultEmpty(boolean errorIfResultEmpty) {
    this.errorIfResultEmpty = errorIfResultEmpty;
    return this;
  }

  /**
   * Find all classes in the search areas, implicitly accepting all of
   * them.
   *
   * @return Collection of found classes
   */
  public Collection<ClassInfo> findClasses() {
    return findClasses(null);
  }

  /**
   * Search all classes in the search areas, keeping only those that
   * pass the specified filter.
   *
   * @param filter  the filter, or null for no filter
   * @return Collection of found classes
   */
  public Collection<ClassInfo> findClasses(ClassFilter filter) {
    Map<String,ClassInfo> foundClasses = new ParallelClassLoader().loadClassesFrom(placesToSearch.values());
    log.info("Loaded " + foundClasses.size() + " classes.");

    Collection<ClassInfo> filteredClasses = filterClasses(filter, foundClasses);

    if (filteredClasses.size() == 0 && errorIfResultEmpty) {
      log.warn("Found no classes, throwing exception");
      throw new ClassFinderException("Didn't find any classes");
    } else {
      log.info("Returning " + filteredClasses.size() + " total classes");
    }
    foundClasses.clear();
    return filteredClasses;
  }

  private Collection<ClassInfo> filterClasses(ClassFilter filter, Map<String, ClassInfo> foundClasses) {
    Collection<ClassInfo> classes = new ArrayList<>();
    for (ClassInfo classInfo : foundClasses.values()) {
      String className = classInfo.getClassName();
      String locationName = classInfo.getClassLocation().getPath();
      log.trace("Looking at " + locationName + " (" + className + ")");
      if ((filter == null) || (filter.accept(classInfo, new ClassHierarchyResolver(foundClasses)))) {
        log.trace("Filter accepted " + className);
        classes.add(classInfo);
      } else {
        log.trace("Filter rejected " + className);
      }
    }
    return classes;
  }
}
public ClassFinder add ( Collection < File > files ) { for ( File file : files ) add ( file ) ; return this ; } public void clear ( ) { placesToSearch . clear ( ) ; } public ClassFinder setErrorIfResultEmpty ( boolean errorIfResultEmpty ) { this . errorIfResultEmpty = errorIfResultEmpty ; return this ; } public Collection < ClassInfo > findClasses ( ) { return findClasses ( null ) ; } public Collection < ClassInfo > findClasses ( ClassFilter filter ) { Map < String , ClassInfo > foundClasses = new ParallelClassLoader ( ) . loadClassesFrom ( placesToSearch . values ( ) ) ; log . info ( "Loaded " + foundClasses . size ( ) + " classes." ) ; Collection < ClassInfo > filteredClasses = filterClasses ( filter , foundClasses ) ; if ( filteredClasses . size ( ) == 0 && errorIfResultEmpty ) { log . warn ( "Found no classes, throwing exception" ) ; throw new ClassFinderException ( "Didn't find any classes" ) ; } else { log . info ( "Returning " + filteredClasses . size ( ) + " total classes" ) ; } foundClasses . clear ( ) ; return filteredClasses ; } private Collection < ClassInfo > filterClasses ( ClassFilter filter , Map < String , ClassInfo > foundClasses ) { Collection < ClassInfo > classes = new ArrayList < > ( ) ; for ( ClassInfo classInfo : foundClasses . values ( ) ) { String className = classInfo . getClassName ( ) ; String locationName = classInfo . getClassLocation ( ) . getPath ( ) ; log . trace ( "Looking at " + locationName + " (" + className + ")" ) ; if ( ( filter == null ) || ( filter . accept ( classInfo , new ClassHierarchyResolver ( foundClasses ) ) ) ) { log . trace ( "Filter accepted " + className ) ; classes . add ( classInfo ) ; } else { log . trace ( "Filter rejected " + className ) ; } } return classes ; } }
Add a <tt>Collection</tt> of jar files, zip files and/or directories
to the list of places to search for classes.

@param files the collection of jar files, zip files and/or directories.
@return this