Package dev.mintychochip.mint
Interface ServiceHolder<T>
- Type Parameters:
T- the service type
@AvailableSince("1.0")
public interface ServiceHolder<T>
Generic priority-based service registry supporting multiple implementations.
Allows registration of multiple service instances with different priorities,
automatically selecting the highest-priority service for get().
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumPredefined priority levels from lowest to highest. -
Method Summary
Modifier and TypeMethodDescriptionget()Returns the highest-priority registered service.getAll()Returns all registered services ordered by priority (highest first).default booleanisLoaded()Checks if any service is currently registered.voidRegisters a service with the specified integer priority.default voidregister(T service, ServiceHolder.Priority priority) Registers a service with the specified enum priority.voidunregister(T service) Removes the specified service from the registry.
-
Method Details
-
register
Registers a service with the specified enum priority.Delegates to
register(Object, int)using the priority's ordinal value.- Parameters:
service- the service instance to registerpriority- the priority level
-
register
Registers a service with the specified integer priority.Higher priority values take precedence. If multiple services have the same priority, the first registered service wins.
- Parameters:
service- the service instance to registerpriority- the priority value (higher = more priority)
-
unregister
Removes the specified service from the registry.- Parameters:
service- the service instance to unregister
-
get
T get()Returns the highest-priority registered service.If multiple services have the same highest priority, returns the first registered.
- Returns:
- the highest-priority service, or
nullif none registered
-
getAll
Returns all registered services ordered by priority (highest first).- Returns:
- list of all services in priority order
-
isLoaded
default boolean isLoaded()Checks if any service is currently registered.- Returns:
trueif at least one service is registered,falseotherwise
-