Interface ServiceDefinition<T>

Type Parameters:
T - The service type
All Known Implementing Classes:
SoftServiceLoader.StaticDefinition

public interface ServiceDefinition<T>
A service that may or may not be present on the classpath.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    default boolean
     
     
    default <X extends Throwable>
    T
    orElseThrow(Supplier<? extends X> exceptionSupplier)
    Load the service of throw the given exception.
  • Method Details

    • getName

      String getName()
      Returns:
      The full class name of the service
    • isPresent

      default boolean isPresent()
      Returns:
      is the service present
    • orElseThrow

      default <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X
      Load the service of throw the given exception.
      Type Parameters:
      X - The exception type
      Parameters:
      exceptionSupplier - The exception supplier
      Returns:
      The instance
      Throws:
      X - The exception concrete type
    • load

      T load()
      Returns:
      load the service