Package net.kyori.adventure.util
Class Services
java.lang.Object
net.kyori.adventure.util.Services
Tools for working with
ServiceLoader
s.- Since:
- 4.8.0
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <P> @NotNull Optional<P>
Locates a service.static <P> Set<P>
Locates all providers for a certain service and initializes them.static <P> @NotNull Optional<P>
serviceWithFallback
(@NotNull Class<P> type) Locates a service.
-
Method Details
-
service
Locates a service.- Type Parameters:
P
- the service type- Parameters:
type
- the service type- Returns:
- a service, or
Optional.empty()
- Since:
- 4.8.0
-
serviceWithFallback
@NotNull public static <P> @NotNull Optional<P> serviceWithFallback(@NotNull @NotNull Class<P> type) Locates a service.If multiple services of this type exist, the first non-fallback service will be returned.
- Type Parameters:
P
- the service type- Parameters:
type
- the service type- Returns:
- a service, or
Optional.empty()
- Since:
- 4.14.0
- See Also:
-
services
Locates all providers for a certain service and initializes them.- Type Parameters:
P
- the service interface type- Parameters:
clazz
- the service interface- Returns:
- an unmodifiable set of all known providers of the service
- Since:
- 4.17.0
-