Interface PooledValue


public interface PooledValue
A Python value evaluated and cached independently in each pooled GraalPy context.

The wrapper borrows a context for each operation and resolves the context-local value before invoking the supplied function. Prefer typed methods such as executeAsString(Object...) when the result is consumed immediately, because the underlying context is returned to the pool before the method returns.

Since:
5.2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default org.graalvm.polyglot.Value
    execute(Object... args)
    Execute the context-local value.
    default boolean
    Execute the context-local value and convert the result to a boolean before releasing the context.
    default String
    Execute the context-local value and convert the result to a string before releasing the context.
    <T> T
    withValue(Function<org.graalvm.polyglot.Value, T> callback)
    Execute a callback with the context-local value.
  • Method Details

    • withValue

      <T> T withValue(Function<org.graalvm.polyglot.Value, T> callback)
      Execute a callback with the context-local value.
      Type Parameters:
      T - The callback result type
      Parameters:
      callback - The callback receiving the value
      Returns:
      The callback result
    • execute

      default org.graalvm.polyglot.Value execute(Object... args)
      Execute the context-local value.
      Parameters:
      args - Arguments to pass to the Python value
      Returns:
      The polyglot result
    • executeAsString

      default String executeAsString(Object... args)
      Execute the context-local value and convert the result to a string before releasing the context.
      Parameters:
      args - Arguments to pass to the Python value
      Returns:
      The string result
    • executeAsBoolean

      default boolean executeAsBoolean(Object... args)
      Execute the context-local value and convert the result to a boolean before releasing the context.
      Parameters:
      args - Arguments to pass to the Python value
      Returns:
      The boolean result