Class Package<T>
java.lang.Object
io.sbk.api.Package<T>
- Type Parameters:
T- discovered implementation type
- Direct Known Subclasses:
RWLoggerPackage, StoragePackage
Utility base class for discovering implementation classes in a package.
This helper enumerates concrete classes of the configured type T
using the concrete subclass's implementation of getClasses(String)
(implementation typically uses a classpath scanner such as Reflections).
It provides convenience methods to list available implementations and to
instantiate them by simple name.
Subclasses should implement getClasses(String) to return the set
of concrete classes for the target package. The class stores the
discovered types in stable arrays and exposes sorted lookup functions used
by the CLI and helper utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInstantiates a discovered implementation by simple class name.getClasses(String packageName) Get the set of Available Storage classes.String[]Returns discovered simple class names in case-insensitive sort order.protected booleanisEmpty()Reports whether discovery found no implementations.voidprintClasses(String header) Logs the discovered implementation names.
-
Constructor Details
-
Package
Discovers concrete implementations in a package.- Parameters:
packageName- package to scan
-
-
Method Details
-
getClasses
-
isEmpty
protected boolean isEmpty()Reports whether discovery found no implementations.- Returns:
truewhen no implementations were found
-
getClassNames
Returns discovered simple class names in case-insensitive sort order.- Returns:
- discovered class names
-
getClass
@NotNull public T getClass(String classNAme) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException Instantiates a discovered implementation by simple class name.- Parameters:
classNAme- case-insensitive simple class name- Returns:
- new implementation instance
- Throws:
ClassNotFoundException- when the name was not discoveredNoSuchMethodException- when the implementation has no default constructorInvocationTargetException- when its constructor failsInstantiationException- when the class cannot be instantiatedIllegalAccessException- when the constructor is inaccessible
-
printClasses
Logs the discovered implementation names.- Parameters:
header- category printed before the class list
-