Class ChainedRPCMethodGenerator
java.lang.Object
eu.cloudnetservice.driver.impl.network.rpc.generation.ChainedRPCMethodGenerator
- All Implemented Interfaces:
RPCMethodGenerator
A method generator that builds another implementation to chain the calls.
- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate(@NonNull CodeBuilder codeBuilder, @NonNull ClassDesc generatingClass, @NonNull RPCGenerationContext context, @NonNull DefaultRPCMethodMetadata targetMethod, @NonNull MethodTypeDesc targetMethodDesc) Generates the method body.private intstoreExtraParameterArray(int[] paramMapping, @NonNull MethodType methodType, @NonNull CodeBuilder codeBuilder) Stores the extra parameter for super constructor invocation according to the provided mappings into an object array which is located at the returned slot.private intstoreRPCChainBase(@NonNull CodeBuilder codeBuilder, @NonNull ClassDesc generatingClass, @NonNull RPCGenerationContext context, @NonNull DefaultRPCMethodMetadata targetMethod) Constructs the base rpc chain for the chained invocation of the method and stores it into the returned slot.private voidvalidateConstructorArgumentMapping(int[] paramMappings, @NonNull DefaultRPCMethodMetadata targetMethod, @NonNull Constructor<?> targetConstructor) Validates that the given parameter mappings match with the method type of the target method and the given resolved constructor from the class that is being implemented.private voidvalidateConstructorArgumentMapping(int[] paramMappings, @NonNull Class<?> chainBaseType, @NonNull DefaultRPCMethodMetadata targetMethod) Ensures that the provided parameter mapping of the user for the method to constructor parameters is valid, by resolving the target constructor that will be called and validating against that.
-
Constructor Details
-
ChainedRPCMethodGenerator
ChainedRPCMethodGenerator()
-
-
Method Details
-
generate
public void generate(@NonNull @NonNull CodeBuilder codeBuilder, @NonNull @NonNull ClassDesc generatingClass, @NonNull @NonNull RPCGenerationContext context, @NonNull @NonNull DefaultRPCMethodMetadata targetMethod, @NonNull @NonNull MethodTypeDesc targetMethodDesc) Generates the method body.- Specified by:
generatein interfaceRPCMethodGenerator- Parameters:
codeBuilder- the code builder of the method body.generatingClass- the descriptor of the class that is being generated.context- the generation context.targetMethod- the target method that is being implemented.targetMethodDesc- the descriptor of the method that is being implemented.
-
storeRPCChainBase
private int storeRPCChainBase(@NonNull @NonNull CodeBuilder codeBuilder, @NonNull @NonNull ClassDesc generatingClass, @NonNull @NonNull RPCGenerationContext context, @NonNull @NonNull DefaultRPCMethodMetadata targetMethod) Constructs the base rpc chain for the chained invocation of the method and stores it into the returned slot.- Parameters:
codeBuilder- the code builder of the method that is being generated.generatingClass- the class that is being generated.context- the context of the current implementation run.targetMethod- the target method that is currently being implemented.- Returns:
- the slot into which the base rpc instance was stored.
- Throws:
NullPointerException- if the given code builder, generating class, context or target method is null.
-
storeExtraParameterArray
private int storeExtraParameterArray(int[] paramMapping, @NonNull @NonNull MethodType methodType, @NonNull @NonNull CodeBuilder codeBuilder) Stores the extra parameter for super constructor invocation according to the provided mappings into an object array which is located at the returned slot.- Parameters:
paramMapping- the mapping of the method parameters to the constructor parameters.methodType- the type of the method that is currently being implemented.codeBuilder- the code builder of the method that is being generated.- Returns:
- the slot into which the extra parameter array was stored.
- Throws:
NullPointerException- if the given method type or code builder is null.
-
validateConstructorArgumentMapping
private void validateConstructorArgumentMapping(int[] paramMappings, @NonNull @NonNull Class<?> chainBaseType, @NonNull @NonNull DefaultRPCMethodMetadata targetMethod) Ensures that the provided parameter mapping of the user for the method to constructor parameters is valid, by resolving the target constructor that will be called and validating against that.- Parameters:
paramMappings- the provided parameter mappings.chainBaseType- the chain base type that will be used as the super class when generating.targetMethod- the target method that is being implemented.- Throws:
NullPointerException- if the given chain base type or target method is null.IllegalStateException- if the provided constructor parameter mappings are invalid.
-
validateConstructorArgumentMapping
private void validateConstructorArgumentMapping(int[] paramMappings, @NonNull @NonNull DefaultRPCMethodMetadata targetMethod, @NonNull @NonNull Constructor<?> targetConstructor) Validates that the given parameter mappings match with the method type of the target method and the given resolved constructor from the class that is being implemented.- Parameters:
paramMappings- the provided parameter mappings.targetMethod- the target method that is being implemented.targetConstructor- the resolved constructor in the chain base class that will be used for invocations.- Throws:
NullPointerException- if the given target method or constructor is null.IllegalStateException- if the provided constructor parameter mappings are invalid.
-