Package io.micronaut.core.io.service
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
getName()
default boolean
isPresent()
T
load()
default <X extends java.lang.Throwable>
TorElseThrow(java.util.function.Supplier<? extends X> exceptionSupplier)
Load the service of throw the given exception.
-
-
-
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 typeX extends java.lang.Throwable
-
load
T load()
- Returns:
- load the service
-
-