Add utility method to get identifying job parameters

This commit is contained in:
Mahmoud Ben Hassine
2023-09-13 16:04:44 +02:00
parent 889dee7ab1
commit 8a6c7ac3c5
3 changed files with 37 additions and 0 deletions

View File

@@ -329,6 +329,21 @@ public class JobParameters implements Serializable {
return Collections.unmodifiableMap(parameters);
}
/**
* Get a map of identifying parameters.
* @since 5.1
* @return an unmodifiable map containing identifying parameters.
*/
public Map<String, JobParameter<?>> getIdentifyingParameters() {
Map<String, JobParameter<?>> identifyingParameters = new HashMap<>();
for (Map.Entry<String, JobParameter<?>> entry : this.parameters.entrySet()) {
if (entry.getValue().isIdentifying()) {
identifyingParameters.put(entry.getKey(), entry.getValue());
}
}
return Collections.unmodifiableMap(identifyingParameters);
}
/**
* @return {@code true} if the parameters object is empty or {@code false} otherwise.
*/

View File

@@ -176,6 +176,9 @@ public class Jackson2ExecutionContextStringSerializer implements ExecutionContex
@JsonIgnore
abstract boolean isEmpty();
@JsonIgnore
abstract Map<String, JobParameter<?>> getIdentifyingParameters();
}
private class JobParameterSerializer extends StdSerializer<JobParameter> {