Package kos.core
Interface ImplementationLoader
-
- All Known Implementing Classes:
ImplementationLoader.SPIImplementationLoader
public interface ImplementationLoaderLoads implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classImplementationLoader.SPIImplementationLoader
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T> Lang.Result<T>anyInstanceOf(Class<T> type)Load the instance of the giventype.<T> Lang.Result<T>instanceOf(Class<T> type)Load the instance of the giventype.default <T> TinstanceOfOrFail(Class<T> type)Load the instance of the giventype.<T> Iterable<T>instancesExposedAs(Class<T> interfaceType)Loads classes exposed by the giveninterfaceType.
-
-
-
Method Detail
-
instancesExposedAs
<T> Iterable<T> instancesExposedAs(Class<T> interfaceType)
Loads classes exposed by the giveninterfaceType.- Type Parameters:
T- same type asinterfaceType- Parameters:
interfaceType- an abstract class or interface in which concrete implementations is expected to be loaded- Returns:
- found implementations or empty
Iterableif none was found.
-
instanceOf
<T> Lang.Result<T> instanceOf(Class<T> type)
Load the instance of the giventype.- Type Parameters:
T- same type astype- Parameters:
type- expected class to be loaded.- Returns:
- an
Optionalinstance containing or not the found instance.
-
instanceOfOrFail
default <T> T instanceOfOrFail(Class<T> type)
Load the instance of the giventype.- Type Parameters:
T- same type astype- Parameters:
type- expected class to be loaded.- Returns:
- found instance
- Throws:
KosException- if not instance was found.
-
anyInstanceOf
default <T> Lang.Result<T> anyInstanceOf(Class<T> type)
Load the instance of the giventype. It will try first to lookup for instances usinginstanceOf(java.lang.Class<T>). If fail, it will return the first one returned byinstancesExposedAs(Class). If none has been found,Optional.empty()will be returned.- Type Parameters:
T- same type astype- Parameters:
type- expected class to be loaded.- Returns:
- an
Optionalinstance containing or not the found instance.
-
-