Skip to content

Commit 7df6197

Browse files
committed
filterClasspathElements -> filterClasspathElementsByURL (#468)
1 parent 4ca3159 commit 7df6197

3 files changed

Lines changed: 11 additions & 21 deletions

File tree

src/main/java/io/github/classgraph/ClassGraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public ClassGraph filterClasspathElements(final ClasspathElementFilter classpath
524524
* should be scanned, and false if not.
525525
* @return this (for method chaining).
526526
*/
527-
public ClassGraph filterClasspathElements(final ClasspathElementURLFilter classpathElementURLFilter) {
527+
public ClassGraph filterClasspathElementsByURL(final ClasspathElementURLFilter classpathElementURLFilter) {
528528
scanSpec.filterClasspathElements(classpathElementURLFilter);
529529
return this;
530530
}

src/main/java/nonapi/io/github/classgraph/classpath/ClasspathOrder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public boolean addClasspathEntry(final Object pathElement, final ClassLoader cla
317317
: new URL(pathElement.toString());
318318
} catch (final MalformedURLException e1) {
319319
if (log != null) {
320-
log.log("Cannot convert from URI to URL: " + pathElementStr);
320+
log.log("Cannot convert to URL: " + pathElement);
321321
}
322322
pathElementURL = null;
323323
}

src/main/java/nonapi/io/github/classgraph/scanspec/ScanSpec.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,33 +307,23 @@ public void addClasspathOverride(final Object overrideClasspathElement) {
307307
}
308308

309309
/**
310-
* Add a classpath element filter. The provided {@link ClasspathElementFilter} should return true if the path
311-
* string passed to it is a path you want to scan.
310+
* Add a classpath element filter. The provided {@link ClasspathElementFilter} or
311+
* {@link ClasspathElementURLFilter} should return true if the path string or {@link URL} passed to it is a path
312+
* that should be scanned.
312313
*
313-
* @param classpathElementFilter
314+
* @param filterLambda
314315
* The classpath element filter to apply to all discovered classpath elements, to decide which should
315316
* be scanned.
316317
*/
317-
public void filterClasspathElements(final ClasspathElementFilter classpathElementFilter) {
318-
if (this.classpathElementFilters == null) {
319-
this.classpathElementFilters = new ArrayList<>(2);
318+
public void filterClasspathElements(final Object filterLambda) {
319+
if (!(filterLambda instanceof ClasspathElementFilter
320+
|| filterLambda instanceof ClasspathElementURLFilter)) {
321+
throw new IllegalArgumentException();
320322
}
321-
this.classpathElementFilters.add(classpathElementFilter);
322-
}
323-
324-
/**
325-
* Add a classpath element URL filter. The provided {@link ClasspathElementURLFilter} should return true if the
326-
* URL passed to it is one you want to scan.
327-
*
328-
* @param classpathElementURLFilter
329-
* The classpath element URL filter to apply to all discovered classpath elements, to decide which
330-
* should be scanned.
331-
*/
332-
public void filterClasspathElements(final ClasspathElementURLFilter classpathElementURLFilter) {
333323
if (this.classpathElementFilters == null) {
334324
this.classpathElementFilters = new ArrayList<>(2);
335325
}
336-
this.classpathElementFilters.add(classpathElementURLFilter);
326+
this.classpathElementFilters.add(filterLambda);
337327
}
338328

339329
/**

0 commit comments

Comments
 (0)