Enum ServiceRegistry
- All Implemented Interfaces:
Serializable
,Comparable<ServiceRegistry>
,java.lang.constant.Constable
Represents the place where
services
are registered and unregistered.
An example service would be that for a
EconomyProvider
.
- Since:
- v1.1.0
- Author:
- MrIvanPlays
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionallServicesFor
(@NotNull Class<T> clazz) boolean
hasRegistration
(@NotNull Class<?> clazz) Returns whether the specified service class has a registration.<T> void
registerService
(@NotNull Class<T> clazz, T service, @NotNull String registrar, @NotNull ServicePriority priority) Register a provider of a service.serviceFor
(@NotNull Class<T> clazz) Queries for a service with the specifiedClass
.void
unregister
(@NotNull Class<?> clazz, @NotNull Object service) Unregister a particular service.void
unregisterAll
(@NotNull String registrar) Unregister all services from a particular registrar.static ServiceRegistry
Returns the enum constant of this type with the specified name.static ServiceRegistry[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
registerService
public <T> void registerService(@NotNull @NotNull Class<T> clazz, @NotNull T service, @NotNull @NotNull String registrar, @NotNull @NotNull ServicePriority priority) Register a provider of a service.- Type Parameters:
T
- provider- Parameters:
clazz
- service classservice
- service to registerregistrar
- who registers this providerpriority
- priority of the service
-
unregisterAll
Unregister all services from a particular registrar.- Parameters:
registrar
- the registrar
-
unregister
Unregister a particular service.- Parameters:
clazz
- service classservice
- service
-
hasRegistration
Returns whether the specified service class has a registration.- Parameters:
clazz
- class to check- Returns:
- boolean value
-
serviceFor
Queries for a service with the specifiedClass
.- Type Parameters:
T
- service type- Parameters:
clazz
- the class to search a service for- Returns:
- service or an empty optional if not present
-
allServicesFor
Returns aSet
copy of all the services found with the providedClass
. If there are no services, it returns an empty set.- Type Parameters:
T
- service type- Parameters:
clazz
- class to find the services of- Returns:
- services
-