Skip to content
Tobias Oberstein edited this page Jun 28, 2017 · 12 revisions

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.


  1. com.example.get_position: returns a 3-positional result (args[0:2]), with each element of type float

  2. com.example.get_kw_position: returns a keywork-based result kwargs['x'], kwargs['y'], kwargs['z'] with each being a float

Calls

TypeReference result_type = new TypeReference<List<Integer>>() {};
session.call("com.example.get_person", null, null, new TypeReference<Person>, null);
List<TypeReference> result_args_types = new ArrayList<>();
result_args_types.add(new TypeReference<Float>() {});
result_args_types.add(new TypeReference<Float>() {});
result_args_types.add(new TypeReference<Float>() {});
session.call("com.example.get_person", null, null, result_args_types, null, null);
Clone this wiki locally