Class ConfigurationBuilder
java.lang.Object
org.reflections.util.ConfigurationBuilder
- All Implemented Interfaces:
Configuration
Configuration builder for instantiating Reflections
// add urls for package prefix, use default scanners
new Reflections(
new ConfigurationBuilder()
.forPackage("org.reflections"))
new Reflections(
new ConfigurationBuilder()
.addUrls(ClasspathHelper.forPackage("org.reflections")) // add urls for package prefix
.addScanners(Scanners.values()) // use all standard scanners
.filterInputsBy(new FilterBuilder().includePackage(...))) // optionally filter inputs
defaults scanners: Scanners.SubTypes and Scanners.TypesAnnotated
(breaking changes) Inputs filter will NOT be set automatically, consider adding in case too many classes are scanned.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddClassLoaders(ClassLoader... classLoaders) add optional class loaders used for resolving types.addScanners(Scanner... scanners) set the scanners instances for scanning different metadataadd urls to be scannedaddUrls(Collection<URL> urls) add urls to be scannedstatic ConfigurationBuilderconstructs aConfigurationBuilder.filterInputsBy(Predicate<String> inputsFilter) sets the input filter for all resources to be scanned.forPackage(String pkg, ClassLoader... classLoaders) forPackages(String... packages) addUrls(URL...)by applyingClasspathHelper.forPackage(String, ClassLoader...)for the givenpackagesoptional class loaders used for resolving types.the fully qualified name filter used to filter types to be scanned.the scanner instances used for indexing metadata.getUrls()the urls to be scanned.booleanscan urls in parallel.setClassLoaders(ClassLoader[] classLoaders) set optional class loaders used for resolving types.setExpandSuperTypes(boolean expandSuperTypes) if set to true, Reflections will expand super types after scanning.setInputsFilter(Predicate<String> inputsFilter) sets the input filter for all resources to be scanned.setParallel(boolean parallel) if true, scan urls in parallel.setScanners(Scanner... scanners) set the scanners instances for scanning different metadataset the urls to be scannedsetUrls(Collection<URL> urls) set the urls to be scannedbooleanif true (default), expand super types after scanning, for super types that were not scanned.
-
Field Details
-
DEFAULT_SCANNERS
-
DEFAULT_INPUTS_FILTER
-
scanners
-
urls
-
inputsFilter
-
isParallel
private boolean isParallel -
classLoaders
-
expandSuperTypes
private boolean expandSuperTypes
-
-
Constructor Details
-
ConfigurationBuilder
public ConfigurationBuilder()
-
-
Method Details
-
build
constructs aConfigurationBuilder.each parameter in
paramsis referred by its type:String- add urls usingClasspathHelper.forPackage(String, ClassLoader...)and an input filterClass- add urls usingClasspathHelper.forClass(Class, ClassLoader...)and an input filterScanner- use scanner, overriding default scannersURL- add url for scanningPredicate- set/override inputs filterClassLoader- use these classloaders in order to find urls using ClasspathHelper and for resolving typesObject[]- flatten and use each element as above
new ConfigurationBuilder().forPackage(...).setScanners(...) -
forPackage
-
forPackages
addUrls(URL...)by applyingClasspathHelper.forPackage(String, ClassLoader...)for the givenpackages -
getScanners
Description copied from interface:Configurationthe scanner instances used for indexing metadata. defaults toSubTypesandTypesAnnotated.- Specified by:
getScannersin interfaceConfiguration
-
setScanners
set the scanners instances for scanning different metadata -
addScanners
set the scanners instances for scanning different metadata -
getUrls
Description copied from interface:Configurationthe urls to be scanned. required.- Specified by:
getUrlsin interfaceConfiguration
-
setUrls
set the urls to be scanneduse
ClasspathHelperconvenient methods to get the relevant urlssee also
forPackages(String...) -
setUrls
set the urls to be scanneduse
ClasspathHelperconvenient methods to get the relevant urlssee also
forPackages(String...) -
addUrls
add urls to be scanneduse
ClasspathHelperconvenient methods to get the relevant urlssee also
forPackages(String...) -
addUrls
add urls to be scanneduse
ClasspathHelperconvenient methods to get the relevant urlssee also
forPackages(String...) -
getInputsFilter
Description copied from interface:Configurationthe fully qualified name filter used to filter types to be scanned. defaults to accept all inputs (if null).- Specified by:
getInputsFilterin interfaceConfiguration
-
setInputsFilter
sets the input filter for all resources to be scanned.prefer using
FilterBuilder -
filterInputsBy
sets the input filter for all resources to be scanned.prefer using
FilterBuilder -
isParallel
public boolean isParallel()Description copied from interface:Configurationscan urls in parallel. defaults to true.- Specified by:
isParallelin interfaceConfiguration
-
setParallel
if true, scan urls in parallel. -
getClassLoaders
Description copied from interface:Configurationoptional class loaders used for resolving types.- Specified by:
getClassLoadersin interfaceConfiguration
-
setClassLoaders
set optional class loaders used for resolving types. -
addClassLoaders
add optional class loaders used for resolving types. -
shouldExpandSuperTypes
public boolean shouldExpandSuperTypes()Description copied from interface:Configurationif true (default), expand super types after scanning, for super types that were not scanned.- Specified by:
shouldExpandSuperTypesin interfaceConfiguration
-
setExpandSuperTypes
if set to true, Reflections will expand super types after scanning.
-