Class ServiceSpigot<Context,Result>

java.lang.Object
cloud.commandframework.services.ServiceSpigot<Context,Result>
Type Parameters:
Context - Context type
Result - Result type

public final class ServiceSpigot<Context,Result> extends Object
Class that outputs results from the given context, using the specified service type
  • Method Details

    • getResult

      public @NonNull Result getResult() throws IllegalStateException, PipelineException
      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
      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 implementation
      IllegalStateException - If a SideEffectService returns null
      PipelineException - Any exceptions thrown during result retrieval from the implementations will be wrapped by PipelineException. Use Throwable.getCause() to get the exception that was thrown.
      PipelineException - Any exceptions thrown during filtering will be wrapped by PipelineException. Use Throwable.getCause() to get the exception that was thrown.
      See Also:
    • getResult

      public void getResult(@NonNull BiConsumer<Result,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 a PipelineException. Thus, the actual exception will be given instead of the wrapper.
      Parameters:
      consumer - Result consumer. If an exception was wrong, the result will be null, otherwise the exception will be non-null and the exception will be null.
      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 implementation
      IllegalStateException - If a SideEffectService returns null
    • getResultAsynchronously

      public @NonNull 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 CompletableFuture<ServicePump<Result>> forwardAsynchronously()
      Forward the request through the original pipeline.
      Returns:
      New pump, for the result of this request