com.transferwise.tasks.domain.TaskContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-tasks-core Show documentation
Show all versions of tw-tasks-core Show documentation
Transferwise Tasks Executor - Fire and forget until Alert.
The newest version!
package com.transferwise.tasks.domain;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class TaskContext {
public static final TaskContext EMPTY = new TaskContext();
private Map contextMap = new HashMap<>();
public T get(String key, Class cls) {
return Optional.ofNullable(contextMap.get(key)).map(cls::cast).orElse(null);
}
public void merge(TaskContext taskContext) {
if (taskContext != null) {
if (taskContext.contextMap != null) {
contextMap.putAll(taskContext.contextMap);
}
}
}
}