Package org.reflections.util
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 ConfigurationBuilder
constructs 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 givenpackages
optional 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.boolean
scan 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 scannedboolean
if 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
params
is 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:Configuration
the scanner instances used for indexing metadata. defaults toSubTypes
andTypesAnnotated
.- Specified by:
getScanners
in interfaceConfiguration
-
setScanners
set the scanners instances for scanning different metadata -
addScanners
set the scanners instances for scanning different metadata -
getUrls
Description copied from interface:Configuration
the urls to be scanned. required.- Specified by:
getUrls
in interfaceConfiguration
-
setUrls
set the urls to be scanneduse
ClasspathHelper
convenient methods to get the relevant urlssee also
forPackages(String...)
-
setUrls
set the urls to be scanneduse
ClasspathHelper
convenient methods to get the relevant urlssee also
forPackages(String...)
-
addUrls
add urls to be scanneduse
ClasspathHelper
convenient methods to get the relevant urlssee also
forPackages(String...)
-
addUrls
add urls to be scanneduse
ClasspathHelper
convenient methods to get the relevant urlssee also
forPackages(String...)
-
getInputsFilter
Description copied from interface:Configuration
the fully qualified name filter used to filter types to be scanned. defaults to accept all inputs (if null).- Specified by:
getInputsFilter
in 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:Configuration
scan urls in parallel. defaults to true.- Specified by:
isParallel
in interfaceConfiguration
-
setParallel
if true, scan urls in parallel. -
getClassLoaders
Description copied from interface:Configuration
optional class loaders used for resolving types.- Specified by:
getClassLoaders
in 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:Configuration
if true (default), expand super types after scanning, for super types that were not scanned.- Specified by:
shouldExpandSuperTypes
in interfaceConfiguration
-
setExpandSuperTypes
if set to true, Reflections will expand super types after scanning.
-