Skip to content
Werner Kunze edited this page Apr 11, 2022 · 12 revisions

Stand With Ukraine

Max Comfort

The following will only allow to call procedures that take positional arguments (only), and return nothing or a single positional result.

However, for such situations, it provides full POJO auto-mapping.

public <T> CompletableFuture<T> call(String procedure,
                                     TypeReference<T> resultType,
                                     CallOptions options,
                                     Object... args)

Single positional returns

ISession

public <T> CompletableFuture<T> call(String procedure,
                                     List<Object> args,
                                     Map<String, Object> kwargs,
                                     TypeReference<T> resultType,
                                     CallOptions options)

Procedure Call Examples

  1. com.example.get_person: returns a single positional result (args[0]) of "complex type Person".
TypeReference resultType = new TypeReference<Person>() {};
session.call("com.example.get_person", null, null, resultType, null);
  1. com.example.get_persons: returns a single positional result (args[0]), which is a list of object of "complex type Person"
TypeReference resultType = new TypeReference<List<Person>>() {};
session.call("com.example.get_persons", null, null, resultType, null);
  1. com.example.get_persons_by_department: returns a single positional result (args[0]), which is a map of strings (department name) to lists of complex objects of type Person
TypeReference resultType = new TypeReference<Map<String, List<Person>>>() {};
session.call("com.example.get_persons_by_department", null, null, resultType, null);

Multi-positional returns

ISession

2-tuple

public <T1, T2> CompletableFuture<TupleOf2<T1, T2>> call(
          String procedure,
          List<Object> args,
          Map<String, Object> kwargs,
          TupleOf2<TypeReference<T1>, TypeReference<T2>> resultTypes,
          CallOptions options)

3-tuple

public <T1, T2, T3> CompletableFuture<TupleOf3<T1, T2, T3>> call(
          String procedure,
          List<Object> args,
          Map<String, Object> kwargs,
          TupleOf3<TypeReference<T1>, TypeReference<T2>, TypeReference<T3>> resultTypes,
          CallOptions options)

4-tuple

and so forth. gets boring.

Procedure Call Examples

  1. com.example.get_foo: returns a 3-positional result (args[0:2]), with the first two being of type float, and the last one being of complex type Person
TupleOf3<TypeReference<Float>,
         TypeReference<Float>,
         TypeReference<Person>> resultTypes = new ???;
session.call("com.example.get_foo", null, null, resultTypes, null);

This would return a CompletableFuture<TupleOf3<Float, Float, Person>>.