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 Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected DataBufprotected NetworkChannelprotected booleanprotected Stringprotected booleanprotected booleanprotected Object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionargumentCount(int argumentCount) Sets the amount of arguments the target method to invoke must have.argumentInformation(@NonNull DataBuf information) Sets the buffer containing the argument information for the method invocation.build()Builds a new invocation context based on the arguments supplied to this builder.channel(@NonNull NetworkChannel channel) Sets the channel from which the request to invoke the method came.expectsMethodResult(boolean expectsResult) Sets if the sender of the rpc expects a method result.methodName(@NonNull String methodName) Sets the name of the method which should get invoked during the requested rpc processing.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.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).workingInstance(@Nullable Object instance) Sets the instance which should get used for method invocation, might be null if no specific instance should be used.
-
Field Details
-
argumentCount
protected int argumentCount -
expectsMethodResult
protected boolean expectsMethodResult -
normalizePrimitives
protected boolean normalizePrimitives -
strictInstanceUsage
protected boolean strictInstanceUsage -
methodName
-
channel
-
arguments
-
workingInstance
-
-
Constructor Details
-
DefaultRPCInvocationContextBuilder
public DefaultRPCInvocationContextBuilder()
-
-
Method Details
-
argumentCount
Sets the amount of arguments the target method to invoke must have.- Specified by:
argumentCountin interfaceRPCInvocationContext.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
Sets if the sender of the rpc expects a method result.- Specified by:
expectsMethodResultin interfaceRPCInvocationContext.Builder- Parameters:
expectsResult- if a method result is expected.- Returns:
- the same builder instance as used to call the method, for chaining.
-
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:
normalizePrimitivesin interfaceRPCInvocationContext.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
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:
strictInstanceUsagein interfaceRPCInvocationContext.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:
methodNamein interfaceRPCInvocationContext.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:
channelin interfaceRPCInvocationContext.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:
argumentInformationin interfaceRPCInvocationContext.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
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:
workingInstancein interfaceRPCInvocationContext.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:
buildin interfaceRPCInvocationContext.Builder- Returns:
- a new invocation context from this builder.
-