Package net.orbyfied.coldlib
Class ColdLib
java.lang.Object
net.orbyfied.coldlib.ColdLib
The library instance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<S extends ColdLibService>
ScreateService(Class<S> sClass, String instanceName) Creates and registers a new service instance of typesClasswith the provided (optional) instance name.static ColdLibget()Get the ColdLib instance from the provider.<S extends ColdLibService>
SgetService(Class<S> sClass) Get a registered service by only class.<S extends ColdLibService>
SgetService(Class<S> sClass, String instanceName) Get a registered service.Get the list of registered services.provider()Get the library provider that instantiated this library.<S extends ColdLibService>
Container<S>referenceService(Class<S> sClass) Get or create a future reference to the specified service instance.<S extends ColdLibService>
Container<S>referenceService(Class<S> sClass, String instanceName) Get or create a future reference to the specified service instance.<S extends ColdLibService>
SwithService(S service) Registers the provided service to this ColdLib instance.
-
Constructor Details
-
ColdLib
-
-
Method Details
-
get
Get the ColdLib instance from the provider.- Returns:
- The ColdLib instance or null if unset.
- Throws:
IllegalStateException- If there is no provider set.- See Also:
-
provider
Get the library provider that instantiated this library.- Returns:
- The provider instance.
-
getServices
Get the list of registered services.- Returns:
- The immutable list of registered services.
-
referenceService
public <S extends ColdLibService> Container<S> referenceService(Class<S> sClass, String instanceName) Get or create a future reference to the specified service instance. This allows you to get, set, or await the service instance in the future.- Type Parameters:
S- The service type.- Parameters:
sClass- The service class.instanceName- The instance name (can be null).- Returns:
- The service reference.
-
referenceService
Get or create a future reference to the specified service instance. This allows you to get, set, or await the service instance in the future.- Type Parameters:
S- The service type.- Parameters:
sClass- The service class.- Returns:
- The service reference.
- See Also:
-
getService
Get a registered service.- Type Parameters:
S- The service type.- Parameters:
sClass- The service class.instanceName- The name (optional).- Returns:
- The service or null if absent.
-
getService
Get a registered service by only class. TheinstanceNameargument will be set to null.- Returns:
- The service or null if absent.
- See Also:
-
withService
Registers the provided service to this ColdLib instance. It use the class of the service object for the service class and the instance name from the service object (can be null)- Type Parameters:
S- The service type.- Parameters:
service- The service instance.- Returns:
- The service (now registered).
-
createService
Creates and registers a new service instance of typesClasswith the provided (optional) instance name.- Type Parameters:
S- The service type.- Parameters:
sClass- The service class.instanceName- The instance name. (can be null)- Returns:
- The service instance (registered).
-