Class cast exception object

Hello @ntheodoropoulos ,

the intention of getVariablesAsType(type) is to deserialize ALL variables to an object.

Given you have variables

{
  "foo": "bar",
  "bif": 3
}

you could create a class

public class MyVariables {
  private String foo;
  private Integer bif;
  
  // getters and setters
}

and then call

MyVariables variables = job.getVariablesAsType(MyVariables.class);
String foo = variables.getFoo() // will return bar
Integer bif = variables.getBif() // will return 3

This will also work for more complex scenarios where a variable value is an object as in the background, a normal objectMapper is working.

  1. It will use the settings of the ObjectMapper used, but by default, it should ignore variables that exist but are not declared in your type.

  2. It will fetch both, you will have to create 2 fields for them.

  3. You could, but the variables as type feature is better :wink:

Jonathan