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 Detail

      • getName

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

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

        default <X extends java.lang.Throwable> T orElseThrow​(java.util.function.Supplier<? extends X> exceptionSupplier)
                                                       throws X extends java.lang.Throwable
        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
        X extends java.lang.Throwable
      • load

        T load()
        Returns:
        load the service