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

io.rouz.flo.TaskContextWithTask Maven / Gradle / Ivy

There is a newer version: 0.0.5
Show newest version
package io.rouz.flo;

import static java.util.Objects.requireNonNull;

import io.rouz.flo.context.ForwardingTaskContext;
import java.util.Optional;

/**
 * A {@link TaskContext} that overrides {@link TaskContext#currentTask()} to return a specific {@link TaskId}.
 */
public class TaskContextWithTask extends ForwardingTaskContext {

  private final Task task;

  private TaskContextWithTask(TaskContext delegate, Task task) {
    super(delegate);
    this.task = requireNonNull(task);
  }

  static TaskContext withTask(TaskContext delegate, Task task) {
    return new TaskContextWithTask(delegate, task);
  }

  @Override
  public Optional> currentTask() {
    return Optional.of(task);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy