Add Engine.getSubsystem
All checks were successful
PRs & Pushes / test (push) Successful in 1m58s
PRs & Pushes / build-jars (push) Successful in 2m21s
PRs & Pushes / build-apidoc (push) Successful in 2m16s

This commit is contained in:
JeremyStar™ 2024-12-27 23:50:54 +01:00
parent 6835823860
commit 246e83c27d
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -27,6 +27,7 @@ import de.staropensource.engine.base.utility.FileAccess
import de.staropensource.engine.base.utility.dnihbd.BuildInformation
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
import kotlin.reflect.KClass
/**
* Primary class of the engine.
@ -102,6 +103,18 @@ class Engine private constructor() {
*/
fun getSubsystems(): Array<Subsystem> = subsystems.toTypedArray()
/**
* Returns the loaded instance
* of the specified [Subsystem].
*
* @since v1-alpha10
*/
fun getSubsystem(subsystemClass: KClass<out Subsystem>): Subsystem? = getSubsystems().find { subsystem -> try {
subsystem::class.qualifiedName!! == subsystemClass.qualifiedName!!
} catch (_: NullPointerException) {
false
} }
/**
* Registers the specified subsystem.
*