holunda-io/camunda-bpm-data

Provide getOrDefault/getLocalOrDefault

Closed this issue · 2 comments

Scenario

  • camunda-bpm-data version: 1.1.1
  • Camunda BPM version: 7.14.x

I am using the CamundaBpmData.reader abstraction to access variables from a DelegateTask.

Current Behaviour

Due to a generic interface that does not enforce full setting of all possible variables, I have to deal with non-existing or empty variables in a null safe way. I am doing

 entity.setMyValue(reader.getOptional(MY_VALUE_VF).orElse(null));
 entity.setMyOtherValue(reader.getOptional(MY_OTHER_VALUE_VF).orElse(null));
 ....

a lot.

Wanted Behaviour

It would be easier to deal with, if I could write

entity.setMyValue(reader.getOrDefault(MY_VALUE_VF, null));

or even

entity.setMyValue(reader.getOrNull(MY_VALUE_VF));

Possible Workarounds

Shown above, works today. This is just some icing on top for convenience usage

PR was merged ...