Skip to content

Commit 105ff40

Browse files
committed
revert
1 parent 25a38b9 commit 105ff40

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

common/src/main/kotlin/com/lambda/command/CommandRegistry.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ object CommandRegistry : Configurable(LambdaConfig), Loadable {
1212
override val name = "command"
1313
val prefix by setting("prefix", ';')
1414

15-
val commands = getInstances<LambdaCommand> { forPackages("com.lambda.command.commands") }.toMutableList()
15+
val commands = getInstances<LambdaCommand> {
16+
forPackages("com.lambda.command.commands"); filterInputsBy { it.contains("com.lambda") }
17+
}.toMutableList()
1618

1719
override fun load(): String {
1820
return "Registered ${commands.size} commands"

common/src/main/kotlin/com/lambda/module/ModuleRegistry.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import org.reflections.util.ConfigurationBuilder
1010
* The [ModuleRegistry] object is responsible for managing all [Module] instances in the system.
1111
*/
1212
object ModuleRegistry : Loadable {
13-
val modules = getInstances<Module> { forPackages("com.lambda.module.modules") }.toMutableList()
13+
val modules = getInstances<Module> {
14+
forPackages("com.lambda.module.modules"); filterInputsBy { it.contains("com.lambda") }
15+
}.toMutableList()
1416

1517
val moduleNames: Set<String>
1618
get() = modules.map { it.name }.toSet()

common/src/main/kotlin/com/lambda/util/reflections/ReflectionsConfigDsl.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ReflectionConfigDsl {
1818
private val packages = mutableListOf<String>()
1919
private val scanners = mutableListOf<Scanners>()
2020
private val urls = mutableListOf<URL>()
21+
private var inputsFilter: (String) -> Boolean = { true }
2122
private val classLoaders = mutableListOf<ClassLoader>()
2223
private var parallel = false
2324
private var shouldExpandSuperTypes = true
@@ -55,6 +56,17 @@ class ReflectionConfigDsl {
5556
return this
5657
}
5758

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
68+
}
69+
5870
/**
5971
* Adds class loaders to the configuration.
6072
*
@@ -89,11 +101,13 @@ class ReflectionConfigDsl {
89101

90102
/**
91103
* Builds a [ConfigurationBuilder] based on the current configuration.
104+
*
105+
* @return A [ConfigurationBuilder] configured with the specified packages, scanners, URLs, filters, and class loaders.
92106
*/
93107
fun build(): ConfigurationBuilder = ConfigurationBuilder()
94108
.forPackages(*packages.toTypedArray())
95109
.addUrls(*urls.toTypedArray())
96-
.filterInputsBy { it.contains("com.lambda") }
110+
.filterInputsBy(inputsFilter)
97111
.addClassLoaders(*classLoaders.toTypedArray())
98112
.setExpandSuperTypes(shouldExpandSuperTypes)
99113
}

0 commit comments

Comments
 (0)