Package kos.api

Interface ImplementationLoader

    • Method Detail

      • instancesExposedAs

        <T> Iterable<T> instancesExposedAs​(Class<T> interfaceType)
        Loads classes exposed by the given interfaceType.
        Type Parameters:
        T - same type as interfaceType
        Parameters:
        interfaceType - an abstract class or interface in which concrete implementations is expected to be loaded
        Returns:
        found implementations or empty Iterable if none was found.
      • instanceOf

        <T> ImplementationLoader.Result<T> instanceOf​(Class<T> type)
        Load the instance of the given type.
        Type Parameters:
        T - same type as type
        Parameters:
        type - expected class to be loaded.
        Returns:
        an Optional instance containing or not the found instance.
      • instanceOfOrFail

        default <T> T instanceOfOrFail​(Class<T> type)
        Load the instance of the given type.
        Type Parameters:
        T - same type as type
        Parameters:
        type - expected class to be loaded.
        Returns:
        found instance
        Throws:
        KosException - if not instance was found.
      • anyInstanceOf

        default <T> ImplementationLoader.Result<T> anyInstanceOf​(Class<T> type)
        Load the instance of the given type. It will try first to lookup for instances using instanceOf(java.lang.Class<T>). If fail, it will return the first one returned by instancesExposedAs(Class). If none has been found, Optional.empty() will be returned.
        Type Parameters:
        T - same type as type
        Parameters:
        type - expected class to be loaded.
        Returns:
        an Optional instance containing or not the found instance.
      • register

        <T> void register​(Class<T> type,
                          T instance)