Class Services

java.lang.Object
net.kyori.adventure.util.Services

public final class Services extends Object
Tools for working with ServiceLoaders.
Since:
4.8.0
  • Method Details

    • service

      @Deprecated(since="5.1.0", forRemoval=true) @ScheduledForRemoval(inVersion="6.0.0") public static <P> Optional<P> service(Class<P> type)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method creates the ServiceLoader in the API module and is not compatible with JPMS service lookup. Use service(ServiceLoader, Class) instead.
      Locates a service.
      Type Parameters:
      P - the service type
      Parameters:
      type - the service type
      Returns:
      a service, or Optional.empty()
      Since:
      4.8.0
    • service

      public static <P> Optional<P> service(ServiceLoader<P> loader, Class<P> type)
      Collects a service from the loader.
      Type Parameters:
      P - the service type
      Parameters:
      loader - the service loader
      type - the service type
      Returns:
      a service, or Optional.empty()
      Since:
      5.1.0
    • serviceWithFallback

      @Deprecated(since="5.1.0", forRemoval=true) @ScheduledForRemoval(inVersion="6.0.0") public static <P> Optional<P> serviceWithFallback(Class<P> type)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method creates the ServiceLoader in the API module and is not compatible with JPMS service lookup. Use serviceWithFallback(ServiceLoader, Class) instead.
      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:
    • serviceWithFallback

      public static <P> Optional<P> serviceWithFallback(ServiceLoader<P> loader, Class<P> type)
      Collects the services.

      If multiple services of this type exist, the first non-fallback service will be returned.

      Type Parameters:
      P - the service type
      Parameters:
      loader - the service loader
      type - the service type
      Returns:
      a service, or Optional.empty()
      Since:
      5.1.0
      See Also:
    • services

      @Deprecated(since="5.1.0", forRemoval=true) @ScheduledForRemoval(inVersion="6.0.0") public static <P> Set<P> services(Class<? extends P> clazz)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method creates the ServiceLoader in the API module and is not compatible with JPMS service lookup. Use services(ServiceLoader, Class) instead.
      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
    • services

      public static <P> Set<P> services(ServiceLoader<? extends P> loader, Class<? extends P> type)
      Collects all providers for a certain service and initializes them.
      Type Parameters:
      P - the service interface type
      Parameters:
      loader - the service loader
      type - the service type
      Returns:
      an unmodifiable set of all known providers of the service
      Since:
      5.1.0