@@ -12,102 +12,70 @@ annotation class ReflectionsDsl
1212 * A DSL class to configure the Reflections library for runtime scanning.
1313 * This class allows you to specify packages, scanners, URLs, filters, class loaders, and other options
1414 * to build a Reflections configuration.
15+ *
16+ * Important!!
17+ * Be aware that using Reflections can lead to unpredictable and hard-to-debug issues.
18+ * Furthermore, the library we're relying on is outdated and no longer maintained.
19+ * For more reliable methods, refer to Reflections.kt.
1520 */
1621@ReflectionsDsl
1722class ReflectionConfigDsl {
1823 private val packages = mutableListOf<String >()
1924 private val scanners = mutableListOf<Scanners >()
2025 private val urls = mutableListOf<URL >()
21- private var inputsFilter: (String ) -> Boolean = { true }
2226 private val classLoaders = mutableListOf<ClassLoader >()
23- private var parallel = false
27+
2428 private var shouldExpandSuperTypes = true
2529
2630 /* *
2731 * Specifies the packages to be scanned.
2832 *
2933 * @param packages A vararg of package names to be included in the scanning process.
30- * @return The current instance of [ReflectionConfigDsl] for method chaining.
3134 */
32- fun forPackages (vararg packages : String ): ReflectionConfigDsl {
35+ fun forPackages (vararg packages : String ) {
3336 this .packages + = packages
34- return this
3537 }
3638
3739 /* *
3840 * Adds scanners to the configuration.
3941 *
4042 * @param scanners A vararg of [Scanners] to be used for scanning classes, methods, etc.
41- * @return The current instance of [ReflectionConfigDsl] for method chaining.
4243 */
43- fun addScanners (vararg scanners : Scanners ): ReflectionConfigDsl {
44+ fun addScanners (vararg scanners : Scanners ) {
4445 this .scanners + = scanners
45- return this
4646 }
4747
4848 /* *
4949 * Adds URLs to the configuration.
5050 *
5151 * @param urls A vararg of [URL] to be included in the scanning process.
52- * @return The current instance of [ReflectionConfigDsl] for method chaining.
5352 */
54- fun addUrls (vararg urls : URL ): ReflectionConfigDsl {
53+ fun addUrls (vararg urls : URL ) {
5554 this .urls + = urls
56- return this
57- }
58-
59- /* *
60- * Sets a filter for input names.
61- *
62- * @param filter A lambda function that takes a [String] and returns a [Boolean], indicating whether the input should be included.
63- * @return The current instance of [ReflectionConfigDsl] for method chaining.
64- */
65- fun filterInputsBy (filter : (String ) -> Boolean ): ReflectionConfigDsl {
66- inputsFilter = filter
67- return this
6855 }
6956
7057 /* *
7158 * Adds class loaders to the configuration.
7259 *
7360 * @param classLoaders A vararg of [ClassLoader] to be used in the scanning process.
74- * @return The current instance of [ReflectionConfigDsl] for method chaining.
7561 */
76- fun addClassLoaders (vararg classLoaders : ClassLoader ): ReflectionConfigDsl {
62+ fun addClassLoaders (vararg classLoaders : ClassLoader ) {
7763 this .classLoaders + = classLoaders
78- return this
7964 }
8065
8166 /* *
82- * Enables parallel scanning.
83- *
84- * @return The current instance of [ReflectionConfigDsl] for method chaining.
67+ * Expand super types during the scan
8568 */
86- fun parallel (): ReflectionConfigDsl {
87- parallel = true
88- return this
89- }
90-
91- /* *
92- * Sets whether to expand super types during scanning.
93- *
94- * @param value A [Boolean] indicating whether to expand super types.
95- * @return The current instance of [ReflectionConfigDsl] for method chaining.
96- */
97- fun expandSuperTypes (value : Boolean ): ReflectionConfigDsl {
98- shouldExpandSuperTypes = value
99- return this
69+ fun expandSuperTypes (shouldExpand : Boolean ) {
70+ shouldExpandSuperTypes = shouldExpand
10071 }
10172
10273 /* *
10374 * Builds a [ConfigurationBuilder] based on the current configuration.
104- *
105- * @return A [ConfigurationBuilder] configured with the specified packages, scanners, URLs, filters, and class loaders.
10675 */
10776 fun build (): ConfigurationBuilder = ConfigurationBuilder ()
10877 .forPackages(* packages.toTypedArray())
10978 .addUrls(* urls.toTypedArray())
110- .filterInputsBy(inputsFilter)
11179 .addClassLoaders(* classLoaders.toTypedArray())
11280 .setExpandSuperTypes(shouldExpandSuperTypes)
11381}
0 commit comments