Class RPCGenerationContext

java.lang.Object
eu.cloudnetservice.driver.impl.network.rpc.generation.RPCGenerationContext

final class RPCGenerationContext extends Object
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
  • Field Details

  • Constructor Details

    • RPCGenerationContext

      public RPCGenerationContext(@NonNull @NonNull RPCGenerationCache generationCache)
      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

      @NonNull public @NonNull List<RPCInternalInstanceFactory> 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.