Class PythonStubGenerator

java.lang.Object
io.micronaut.python.processing.PythonStubGenerator
All Implemented Interfaces:
Ordered, Toggleable, TypeElementVisitor<Object,Object>

public class PythonStubGenerator extends Object implements TypeElementVisitor<Object,Object>
Generates Java stubs for Python classes, scripts, enums, interfaces, and annotations.
  • Field Details

    • POLYGLOT_VALUE

      public static final io.micronaut.sourcegen.model.TypeDef POLYGLOT_VALUE
    • POLYGLOT_CONTEXT

      public static final io.micronaut.sourcegen.model.TypeDef POLYGLOT_CONTEXT
    • CLASS_OBJECT

      public static final io.micronaut.sourcegen.model.VariableDef.StaticField CLASS_OBJECT
    • AS_POLYGLOT_VALUE

      public static final String AS_POLYGLOT_VALUE
      See Also:
    • RECONSTRUCT_POLYGLOT_VALUE

      public static final String RECONSTRUCT_POLYGLOT_VALUE
      See Also:
    • FROM_POLYGLOT_VALUE

      public static final String FROM_POLYGLOT_VALUE
      See Also:
    • PYTHON_COERCION

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_COERCION
    • VALUE_COERCIBLES

      public static final io.micronaut.sourcegen.model.ClassTypeDef VALUE_COERCIBLES
    • PYTHON_CONVERSION

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_CONVERSION
    • PYTHON_EXCEPTIONS

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_EXCEPTIONS
    • PYTHON_HTTP_CONVERSION

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_HTTP_CONVERSION
    • PYTHON_INVOCATION

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_INVOCATION
    • PYTHON_ASYNCIO_RUNTIME

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_ASYNCIO_RUNTIME
    • PYTHON_CONTEXT_RUNTIME

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_CONTEXT_RUNTIME
    • PYTHON_JAVA_BASES

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_JAVA_BASES
    • PYTHON_CLASS_REFERENCE

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_CLASS_REFERENCE
    • PYTHON_CLASS_ANNOTATION

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_CLASS_ANNOTATION
    • PYTHON_MODULE_ANNOTATION

      public static final io.micronaut.sourcegen.model.ClassTypeDef PYTHON_MODULE_ANNOTATION
    • POLYGLOT_VALUE_CONVERTER

      public static final io.micronaut.sourcegen.model.ClassTypeDef POLYGLOT_VALUE_CONVERTER
    • INTERCEPTED_PROXY

      public static final io.micronaut.sourcegen.model.ClassTypeDef INTERCEPTED_PROXY
      The type of a proxy that intercepts a target bean; a generated stub that is one has no Python object of its own.
    • GENERATOR_NAME

      public static final String GENERATOR_NAME
      See Also:
    • JUNIT_TEST

      public static final String JUNIT_TEST
      See Also:
    • ANN_JSON_PROPERTY

      public static final String ANN_JSON_PROPERTY
      See Also:
    • ANN_JSON_CREATOR

      public static final String ANN_JSON_CREATOR
      See Also:
  • Constructor Details

    • PythonStubGenerator

      public PythonStubGenerator()
  • Method Details

    • query

      public TypeElementQuery query()
      Description copied from interface: TypeElementVisitor
      The query which allows to reduce the scope which the visitor is visiting.
      Specified by:
      query in interface TypeElementVisitor<Object,Object>
      Returns:
      The query if the visitor.
    • getSupportedOptions

      public Set<String> getSupportedOptions()
      The annotation processor options this visitor reads, so that javac does not report them as options no processor recognized - a warning, and with -Werror a compilation error, for a user who passes one of them.

      Declaring an option here is also what makes it settable from an application's configuration under Pyronaut, which passes every supported option it finds in application.toml through as -A. An option the visitor reads but does not declare can only be set by hand.

      Specified by:
      getSupportedOptions in interface TypeElementVisitor<Object,Object>
      Returns:
      The names of the -A options this visitor reads
    • finish

      public void finish(VisitorContext visitorContext)
      Description copied from interface: TypeElementVisitor
      Called once when visitor processing finishes.
      Specified by:
      finish in interface TypeElementVisitor<Object,Object>
      Parameters:
      visitorContext - The visitor context
    • start

      public void start(VisitorContext visitorContext)
      Description copied from interface: TypeElementVisitor
      Called once when visitor processing starts.
      Specified by:
      start in interface TypeElementVisitor<Object,Object>
      Parameters:
      visitorContext - The visitor context
    • visitClass

      public void visitClass(ClassElement element, VisitorContext context)
      Description copied from interface: TypeElementVisitor
      Executed when a class is encountered that matches the <C> generic.
      Specified by:
      visitClass in interface TypeElementVisitor<Object,Object>
      Parameters:
      element - The element
      context - The visitor context
    • bridgeProducerMethod

      public void bridgeProducerMethod(PythonMethodElement producerMethod, VisitorContext visitorContext)
      Bridges a producer method of an associated bean into the stub of the Python class that declares it. The child bean definition written for the method invokes it on the generated Java class, and a Python method is only bridged into the stub when Micronaut needs to see it.
      Parameters:
      producerMethod - The producer method registered with BeanElementBuilder.produceBeans(...)
      visitorContext - The visitor context
    • getVisitorKind

      public TypeElementVisitor.VisitorKind getVisitorKind()
      Specified by:
      getVisitorKind in interface TypeElementVisitor<Object,Object>
      Returns:
      The visitor kind.