Package cloud.commandframework.services
Class ServiceSpigot<Context,Result>
java.lang.Object
cloud.commandframework.services.ServiceSpigot<Context,Result>
- Type Parameters:
Context- Context typeResult- Result type
Class that outputs results from the given context, using the specified service type
-
Method Summary
Modifier and TypeMethodDescription@NonNull ServicePump<Result>forward()Forward the request through the original pipeline.@NonNull CompletableFuture<ServicePump<Result>>Forward the request through the original pipeline.@NonNull ResultGet the first result that is generated for the given context.voidgetResult(@NonNull BiConsumer<Result, Throwable> consumer) Get the first result that is generated for the given context.@NonNull CompletableFuture<Result>Get the first result that is generated for the given context.
-
Method Details
-
getResult
Get the first result that is generated for the given context. This cannot returnnull. If nothing manages to produce a result, an exception will be thrown. If the pipeline has been constructed properly, this will never happen.- Returns:
- Generated result
- Throws:
IllegalStateException- If no result was found. This only happens if the pipeline has not been constructed properly. The most likely cause is a faulty default implementationIllegalStateException- If aSideEffectServicereturnsnullPipelineException- Any exceptions thrown during result retrieval from the implementations will be wrapped byPipelineException. UseThrowable.getCause()to get the exception that was thrown.PipelineException- Any exceptions thrown during filtering will be wrapped byPipelineException. UseThrowable.getCause()to get the exception that was thrown.- See Also:
-
getResult
Get the first result that is generated for the given context. If nothing manages to produce a result, an exception will be thrown. If the pipeline has been constructed properly, this will never happen. The exception passed to the consumer will be unwrapped, in the case that it's aPipelineException. Thus, the actual exception will be given instead of the wrapper.- Parameters:
consumer- Result consumer. If an exception was wrong, the result will benull, otherwise the exception will be non-null and the exception will benull.- Throws:
IllegalStateException- If no result was found. This only happens if the pipeline has not been constructed properly. The most likely cause is a faulty default implementationIllegalStateException- If aSideEffectServicereturnsnull
-
getResultAsynchronously
Get the first result that is generated for the given context. This cannot return null. If nothing manages to produce a result, an exception will be thrown. If the pipeline has been constructed properly, this will never happen.- Returns:
- Generated result
-
forward
Forward the request through the original pipeline.- Returns:
- New pump, for the result of this request
-
forwardAsynchronously
Forward the request through the original pipeline.- Returns:
- New pump, for the result of this request
-