Package net.kyori.adventure.util
Class Services
- java.lang.Object
-
- net.kyori.adventure.util.Services
-
public final class Services extends java.lang.Object
Tools for working withServiceLoader
s.- Since:
- 4.8.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Services.Fallback
A fallback service.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <P> @NotNull java.util.Optional<P>
service(@NotNull java.lang.Class<P> type)
Locates a service.static <P> @NotNull java.util.Optional<P>
serviceWithFallback(@NotNull java.lang.Class<P> type)
Locates a service.
-
-
-
Method Detail
-
service
@NotNull public static <P> @NotNull java.util.Optional<P> service(@NotNull @NotNull java.lang.Class<P> type)
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 java.util.Optional<P> serviceWithFallback(@NotNull @NotNull java.lang.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.Fallback
-
-