saker.build Documentation TaskDoc JavaDoc Packages
public interface TaskResultDependencyHandle
Handle to a task result that allows modifying the applied dependency to the underlying task.

This interface provides access to a task result that was associated with it during construction time. The interface optionally supports modifying the applied dependency to the associated task. Specifying the dependency via setTaskOutputChangeDetector(TaskOutputChangeDetector) may not always have an effect, and it is implementation dependent.

The interface doesn't define the manner of how the task result is retrieved, and it is implementation dependent based on the context.

This interface mainly exists to make fine graining dependency application possible using TaskResultResolver and when working with structured task results.
Working with objects that have their values backed by task results may occur when the build task executions are already finished. In these cases, a TaskResultResolver instance can be used to retrieve task results for given task identifiers. However, when working with the same data during task execution, the task dependencies may need to be refined for proper incremental implementation. As the objects have a TaskResultResolver reference instead of TaskContext, without the use of this interface the dependency reification would not be possible, although it is necessary by the consumers.

By using this interface, the task result consumers can have a common interface to work with task results that support dependency reification and with those that don't. If the TaskOutputChangeDetector cannot be set, the implementations will silently ignore.

This interface may be implemented by clients.

Methods
public TaskResultDependencyHandle
Clones the dependency handle, returning a clean one.
public static TaskResultDependencyHandle
create(Object resultobject)
Creates a simple TaskResultDependencyHandle that returns the argument object.
public Object
get()
Gets the task result for the associated task.
public default void
Sets the output change detector for the associated task dependency.
Clones the dependency handle, returning a clean one.

The returned dependency handle is semantically the same as if it was newly retrieved from the same method as this handle.

The cloned dependency handle.
public static TaskResultDependencyHandle create(Object resultobject)
Creates a simple TaskResultDependencyHandle that returns the argument object.

The returned dependency handle has no dependency support, only a simple wrapper for the specified object.

resultobjectThe backing object.
The created dependency handle.
public abstract Object get() throws RuntimeException
Gets the task result for the associated task.

The behaviour of this method is implementation dependent, it may wait for the associated task to finish.

If setTaskOutputChangeDetector(TaskOutputChangeDetector) is not called on an instance after retrieving the result, an implementation dependent dependency may be installed. (Most commonly an equivalent dependency to CommonTaskOutputChangeDetector.ALWAYS.)

The result of this call may or may not be an instance of StructuredTaskResult based on the associated context the TaskResultDependencyHandle was retrieved from.

The task result.
RuntimeExceptionIf the task result retrieval failed. It may be because the task execution failed, waiting for the task failed, or any other implementation dependent reasons.
Sets the output change detector for the associated task dependency.

Works the same way as TaskDependencyFuture.setTaskOutputChangeDetector(TaskOutputChangeDetector).

Implementations that don't support this method must silently ignore it. If they don't support it, and task dependencies make sense in the associated context, then a dependency equivalent to CommonTaskOutputChangeDetector.ALWAYS must be installed.

Implementations may require that get() is called before setting the task output change detector and may throw IllegalStateException in case this requirement is violated.

outputchangedetectorThe output change detector.
IllegalStateExceptionIf the method is called at an inaproppriate time. (E.g. the task is not yet finished)
NullPointerExceptionIf the change detector is null.