se.l4.jobs.engine.internal.JobImpl Maven / Gradle / Ivy
The newest version!
package se.l4.jobs.engine.internal;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import se.l4.jobs.Job;
import se.l4.jobs.JobData;
import se.l4.jobs.engine.QueuedJob;
/**
* Implementation of {@link Job} as returned by {@link LocalJobsImpl}.
*
* @param
* @param
*/
public class JobImpl, R>
implements Job
{
private final LocalJobsImpl jobs;
private final QueuedJob job;
private final CompletableFuture result;
public JobImpl(
LocalJobsImpl jobs,
QueuedJob job,
CompletableFuture result
)
{
this.jobs = jobs;
this.job = job;
this.result = result;
}
@Override
public Optional getId()
{
return job.getKnownId();
}
@Override
public D getData()
{
return job.getData();
}
@Override
public CompletableFuture result()
{
return result;
}
@Override
public void cancel()
{
jobs.cancel(job.getId());
}
}