Package cloud.commandframework.services
Class ServiceSpigot<Context,Result>
- java.lang.Object
-
- cloud.commandframework.services.ServiceSpigot<Context,Result>
-
- Type Parameters:
Context- Context typeResult- Result type
public final class ServiceSpigot<Context,Result> extends java.lang.ObjectClass that outputs results from the given context, using the specified service type
-
-
Method Summary
Modifier and Type Method Description @NonNull ServicePump<Result>forward()Forward the request through the original pipeline.@NonNull java.util.concurrent.CompletableFuture<ServicePump<Result>>forwardAsynchronously()Forward the request through the original pipeline.@NonNull ResultgetResult()Get the first result that is generated for the given context.voidgetResult(@NonNull java.util.function.BiConsumer<Result,java.lang.Throwable> consumer)Get the first result that is generated for the given context.@NonNull java.util.concurrent.CompletableFuture<Result>getResultAsynchronously()Get the first result that is generated for the given context.
-
-
-
Method Detail
-
getResult
public @NonNull Result getResult() throws java.lang.IllegalStateException, PipelineException
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:
java.lang.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 implementationjava.lang.IllegalStateException- 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:
PipelineException wraps exceptions thrown during filtering and result retrieval
-
getResult
public void getResult(@NonNull java.util.function.BiConsumer<Result,java.lang.Throwable> consumer)
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:
java.lang.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 implementationjava.lang.IllegalStateException- If aSideEffectServicereturnsnull
-
getResultAsynchronously
public @NonNull java.util.concurrent.CompletableFuture<Result> 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
public @NonNull ServicePump<Result> forward()
Forward the request through the original pipeline.- Returns:
- New pump, for the result of this request
-
forwardAsynchronously
public @NonNull java.util.concurrent.CompletableFuture<ServicePump<Result>> forwardAsynchronously()
Forward the request through the original pipeline.- Returns:
- New pump, for the result of this request
-
-