Class DefaultRPCInvocationContextBuilder

java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.handler.context.DefaultRPCInvocationContextBuilder
All Implemented Interfaces:
RPCInvocationContext.Builder

public class DefaultRPCInvocationContextBuilder extends Object implements RPCInvocationContext.Builder
The default implementation of a rpc invocation context builder.
Since:
4.0
See Also:
  • Field Details

    • argumentCount

      protected int argumentCount
    • expectsMethodResult

      protected boolean expectsMethodResult
    • normalizePrimitives

      protected boolean normalizePrimitives
    • strictInstanceUsage

      protected boolean strictInstanceUsage
    • methodName

      protected String methodName
    • channel

      protected NetworkChannel channel
    • arguments

      protected DataBuf arguments
    • workingInstance

      protected Object workingInstance
  • Constructor Details

    • DefaultRPCInvocationContextBuilder

      public DefaultRPCInvocationContextBuilder()
  • Method Details

    • argumentCount

      @NonNull public RPCInvocationContext.Builder argumentCount(int argumentCount)
      Sets the amount of arguments the target method to invoke must have.
      Specified by:
      argumentCount in interface RPCInvocationContext.Builder
      Parameters:
      argumentCount - the amount of arguments the target method must have.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • expectsMethodResult

      @NonNull public RPCInvocationContext.Builder expectsMethodResult(boolean expectsResult)
      Sets if the sender of the rpc expects a method result.
      Specified by:
      expectsMethodResult in interface RPCInvocationContext.Builder
      Parameters:
      expectsResult - if a method result is expected.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • normalizePrimitives

      @NonNull public RPCInvocationContext.Builder normalizePrimitives(boolean normalizePrimitives)
      Sets if primitives should get normalized, meaning that if a null value is returned in a call chain but the method returns a primitive type, the response will be the default value of that primitive rather than null.
      Specified by:
      normalizePrimitives in interface RPCInvocationContext.Builder
      Parameters:
      normalizePrimitives - if nulls should get normalized if a primitive is expected.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • strictInstanceUsage

      @NonNull public RPCInvocationContext.Builder strictInstanceUsage(boolean strictInstanceUsage)
      Sets if the handler is only allowed to use the supplied instance through the invocation context rather than the instance it is bound to (if any).
      Specified by:
      strictInstanceUsage in interface RPCInvocationContext.Builder
      Parameters:
      strictInstanceUsage - if the instance usage for method invocation should be strict.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • methodName

      Sets the name of the method which should get invoked during the requested rpc processing.
      Specified by:
      methodName in interface RPCInvocationContext.Builder
      Parameters:
      methodName - the name of the method to call.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • channel

      Sets the channel from which the request to invoke the method came.
      Specified by:
      channel in interface RPCInvocationContext.Builder
      Parameters:
      channel - the channel to which the request was sent.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • argumentInformation

      @NonNull public RPCInvocationContext.Builder argumentInformation(@NonNull @NonNull DataBuf information)
      Sets the buffer containing the argument information for the method invocation. The buffer is allowed to hold more information than that AFTER the method arguments.
      Specified by:
      argumentInformation in interface RPCInvocationContext.Builder
      Parameters:
      information - the buffer holding the arguments for the method call.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • workingInstance

      @NonNull public RPCInvocationContext.Builder workingInstance(@Nullable @Nullable Object instance)
      Sets the instance which should get used for method invocation, might be null if no specific instance should be used. If strict instance usage is active and no instance was supplied through the method, the result of the rpc invocation will always be null (or a normalized primitive value if active).
      Specified by:
      workingInstance in interface RPCInvocationContext.Builder
      Parameters:
      instance - the instance to use for method calls.
      Returns:
      the same builder instance as used to call the method, for chaining.
    • build

      Builds a new invocation context based on the arguments supplied to this builder.
      Specified by:
      build in interface RPCInvocationContext.Builder
      Returns:
      a new invocation context from this builder.