- Type Parameters:
Context- Context type, this will be the input that is used to generate the response
Result- Response type, this is what is produced by the service ("provided")
- All Known Subinterfaces:
- All Known Implementing Classes:
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Service<Context,Result> extends Function<@NonNull Context,@Nullable Result>A service is anything that can take in a context, and produce a response. Most service implementations will be side effect free, although some service implementations will have side effects. Those that do, should be clearly labeled
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description
default @Nullable Result
apply(@NonNull Context context)
handle(@NonNull Context context)Provide a response for the given context.
default @Nullable ExecutionOrder
order()Get the execution order of the service.
handleProvide a response for the given context. If the service implementation cannot provide a response for the given context, it should return
context- Context used in the generation of the response
- Response. If the response isn't
null, the next service in the service chain will get to act on the context. Otherwise the execution halts, and the provided response is the final response.
Exception- Any exception that occurs during the handling can be thrown, and will be wrapped by a