Class RPCGenerationContext
java.lang.Object
eu.cloudnetservice.driver.impl.network.rpc.generation.RPCGenerationContext
Contextual information that are available during the complete generation process. For example used to collect fields
that will be generated into the class after all other generation finishes.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordA field that holds an additional instance factory that is accessed to allocate instances of chain classes.private static final recordInformation about the request of adding a type descriptor field into the final class. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<RPCGenerationContext.AdditionalInstanceFactoryField> private final RPCGenerationCache(package private) MethodTypeDescprivate final Set<RPCGenerationContext.TypeDescriptorField> -
Constructor Summary
ConstructorsConstructorDescriptionRPCGenerationContext(@NonNull RPCGenerationCache generationCache) Constructs a new rpc generation context. -
Method Summary
Modifier and TypeMethodDescriptionGet the additional instance factories that were registered during the implementation build process.intGet the count of additional instance factories that were registered.voidapplyToClassAndConstructor(@NonNull ClassDesc generatingClass, @NonNull ClassBuilder classBuilder, @NonNull CodeBuilder constructorCode) Registers everything in this context to the class and constructor of the class.registerAdditionalInstanceFactory(int generationFlags, @NonNull Class<?> superType, @NonNull Class<?> baseImplementation) Registers an additional instance factory that will be injected into the generated class during instantiation.registerAdditionalInstanceFactory(@NonNull Class<?> targetType, @NonNull RPCInternalInstanceFactory factory) Registers an additional instance factory that will be injected into the generated class during instantiation.registerTypeDescriptorField(@NonNull DefaultRPCMethodMetadata methodMetadata) Registers the need for a type descriptor field for the given method metadata and returns the field name of the final field that will be added and initialized to the class.
-
Field Details
-
generationCache
-
typeDescriptorFields
-
additionalInstanceFactoriesFields
private final Set<RPCGenerationContext.AdditionalInstanceFactoryField> additionalInstanceFactoriesFields -
superclassConstructorDesc
MethodTypeDesc superclassConstructorDesc
-
-
Constructor Details
-
RPCGenerationContext
Constructs a new rpc generation context.- Parameters:
generationCache- the cache for generated class implementation.- Throws:
NullPointerException- if the given cache is null.
-
-
Method Details
-
additionalInstanceFactoryCount
public int additionalInstanceFactoryCount()Get the count of additional instance factories that were registered.- Returns:
- the count of additional instance factories that were registered.
-
additionalInstanceFactories
Get the additional instance factories that were registered during the implementation build process.- Returns:
- the additional instance factories registered during the implementation build.
-
registerAdditionalInstanceFactory
@NonNull public @NonNull String registerAdditionalInstanceFactory(int generationFlags, @NonNull @NonNull Class<?> superType, @NonNull @NonNull Class<?> baseImplementation) Registers an additional instance factory that will be injected into the generated class during instantiation.- Parameters:
generationFlags- the options to apply during class generation.superType- the target type that is constructed by the instance factory.baseImplementation- the base implementation class for the super type, can be the same as the super type.- Returns:
- the name of the final factory field to access it.
- Throws:
NullPointerException- if the given super type or base implementation is null.
-
registerAdditionalInstanceFactory
@NonNull public @NonNull String registerAdditionalInstanceFactory(@NonNull @NonNull Class<?> targetType, @NonNull @NonNull RPCInternalInstanceFactory factory) Registers an additional instance factory that will be injected into the generated class during instantiation.- Parameters:
targetType- the target type that is constructed by the instance factory.factory- the instance factory that should be assigned to the field.- Returns:
- the name of the final factory field to access it.
- Throws:
NullPointerException- if the given target type or instance factory is null.
-
registerTypeDescriptorField
@NonNull public @NonNull String registerTypeDescriptorField(@NonNull @NonNull DefaultRPCMethodMetadata methodMetadata) Registers the need for a type descriptor field for the given method metadata and returns the field name of the final field that will be added and initialized to the class.- Parameters:
methodMetadata- the method metadata for which the descriptor field should be registered.- Returns:
- the name of the final descriptor field to access it.
- Throws:
NullPointerException- if the given method metadata is null.
-
applyToClassAndConstructor
public void applyToClassAndConstructor(@NonNull @NonNull ClassDesc generatingClass, @NonNull @NonNull ClassBuilder classBuilder, @NonNull @NonNull CodeBuilder constructorCode) Registers everything in this context to the class and constructor of the class.- Parameters:
generatingClass- the descriptor of the class that is being generated.classBuilder- the builder of the class being generated.constructorCode- the builder of the constructor code for the current class.- Throws:
NullPointerException- if the current class desc, class builder or constructor builder is null.
-