-
Notifications
You must be signed in to change notification settings - Fork 227
/
ClassScanner.java
68 lines (59 loc) · 2.3 KB
/
ClassScanner.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright 2015, Yahoo Inc.
* Licensed under the Apache License, Version 2.0
* See LICENSE file in project root for terms.
*/
package com.yahoo.elide.core.utils;
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Set;
/**
* Scans a package for classes by looking at files in the classpath.
*/
public interface ClassScanner {
/**
* Scans all classes accessible from the context class loader which belong to the given package and subpackages.
*
* @param toScan package to scan
* @param annotation Annotation to search
* @return The classes
*/
Set<Class<?>> getAnnotatedClasses(Package toScan, Class<? extends Annotation> annotation);
/**
* Scans all classes accessible from the context class loader which belong to the given package and subpackages.
*
* @param packageName package name to scan.
* @param annotation Annotation to search
* @return The classes
*/
Set<Class<?>> getAnnotatedClasses(String packageName, Class<? extends Annotation> annotation);
/**
* Scans all classes accessible from the context class loader which belong to the current class loader.
* Filters the final output based on expression.
* @param annotations One or more annotation to search for
* @param filter filter expression to include the final results in the output.
* @return The classes
*/
Set<Class<?>> getAnnotatedClasses(List<Class<? extends Annotation>> annotations, FilterExpression filter);
/**
* Scans all classes accessible from the context class loader which belong to the current class loader.
*
* @param annotations One or more annotation to search for
* @return The classes
*/
Set<Class<?>> getAnnotatedClasses(List<Class<? extends Annotation>> annotations);
Set<Class<?>> getAnnotatedClasses(Class<? extends Annotation> ... annotations);
/**
* Returns all classes within a package.
* @param packageName The root package to search.
* @return All the classes within a package.
*/
Set<Class<?>> getAllClasses(String packageName);
/**
* Function which will be invoked for deciding to include the class in final results.
*/
@FunctionalInterface
interface FilterExpression {
boolean include(Class clazz);
}
}