Class Package<T>

java.lang.Object
io.sbk.api.Package<T>
Type Parameters:
T - discovered implementation type
Direct Known Subclasses:
RWLoggerPackage, StoragePackage

public abstract class Package<T> extends Object
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 Details

    • Package

      public Package(String packageName)
      Discovers concrete implementations in a package.
      Parameters:
      packageName - package to scan
  • Method Details

    • getClasses

      public abstract Set<Class<? extends T>> getClasses(String packageName)
      Get the set of Available Storage classes.
      Parameters:
      packageName - Name of the package.
      Returns:
      Set of classes extends Storage class
    • isEmpty

      protected boolean isEmpty()
      Reports whether discovery found no implementations.
      Returns:
      true when no implementations were found
    • getClassNames

      public String[] getClassNames()
      Returns discovered simple class names in case-insensitive sort order.
      Returns:
      discovered class names
    • getClass

      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 discovered
      NoSuchMethodException - when the implementation has no default constructor
      InvocationTargetException - when its constructor fails
      InstantiationException - when the class cannot be instantiated
      IllegalAccessException - when the constructor is inaccessible
    • printClasses

      public void printClasses(String header)
      Logs the discovered implementation names.
      Parameters:
      header - category printed before the class list