Class PythonValues

java.lang.Object
io.micronaut.python.processing.util.PythonValues

@Internal public final class PythonValues extends Object
Converts the literal values the Python processor produces (decorator arguments, attribute initialisers, parameter defaults) into plain Java values at the language boundary, so the rest of the compiler never handles a polyglot Value.

Literals map to their natural Java type: str to String, bool to Boolean, int to Integer or Long, float to Double, lists and tuples to List, dicts to Map. Host objects (a DecoratorDef, a TypeRef, a Java class) pass through. A Python object that is none of these, for example a dataclasses.Field, is kept as the Value it is.

Since:
5.2.0
  • Method Details

    • toJava

      @Nullable public static @Nullable Object toJava(@Nullable @Nullable Object value)
      Converts a value received from the processor.
      Parameters:
      value - The value, which may already be a Java object
      Returns:
      The Java value
    • toJava

      @Nullable public static @Nullable Object toJava(@Nullable @Nullable org.graalvm.polyglot.Value value)
      Converts a polyglot value received from the processor.
      Parameters:
      value - The polyglot value
      Returns:
      The Java value
    • toJava

      @Nullable public static @Nullable Map<String,Object> toJava(@Nullable @Nullable Map<String,?> values)
      Converts every value of a map received from the processor.
      Parameters:
      values - The values keyed by member name
      Returns:
      A new map with Java values, or the same map when it is null