Class JavaLambdaFactory

java.lang.Object
io.deephaven.integrations.python.JavaLambdaFactory

public class JavaLambdaFactory extends Object
Tool to wrap Python Callables into Java functional interfaces. Useful for Java-aware Python code to implement Java functional interfaces to pass callbacks/handlers/etc to Python-oblivious Java APIs.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    create(Class<T> samInterface, org.jpy.PyObject callable, Class<?> coerceToType)
    Wraps a python callable in a java functional interface, with an optional extra step to coerce a returned value to handle Deephaven nulls.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JavaLambdaFactory

      public JavaLambdaFactory()
  • Method Details

    • create

      public static <T> T create(Class<T> samInterface, org.jpy.PyObject callable, @Nullable Class<?> coerceToType)
      Wraps a python callable in a java functional interface, with an optional extra step to coerce a returned value to handle Deephaven nulls.
      Type Parameters:
      T - the type of the lambda to return
      Parameters:
      samInterface - the Java interface to wrap the callable in. If this has more than one abstract method, an exception will be thrown.
      callable - The Python Callable to wrap
      coerceToType - An optional, expected return type for the Callable to return.
      Returns:
      a Java functional interface implementation