All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.transferwise.tasks.domain.TaskContext Maven / Gradle / Ivy

There is a newer version: 1.43.0
Show 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);
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy