package com.atlassian.stash.internal.task.property;

import com.atlassian.bitbucket.comment.CommentPropertyContext;
import com.atlassian.stash.internal.task.InternalTask;
import com.atlassian.stash.internal.task.InternalTaskContextVisitor;

import javax.annotation.Nonnull;

/**
 * Allows iterating and adding properties on tasks.
 *
 * @see CommentPropertyContext
 */
// This interface should be moved to the SPI module if providing task properties is made a public API,
// for consistency with the comment and pull request properties' API.
public interface TaskPropertyContext extends Iterable<InternalTask> {

    /**
     * Visit the {@link com.atlassian.stash.internal.task.InternalTaskContext InternalTaskContext}
     * the task is associated with.
     */
    <T> T accept(InternalTaskContextVisitor<T> visitor);

    /**
     * AAdds a property to the {@code task}. Any existing property stored under {@code key} will be replaced.
     *
     * @param task  task that will receive the property
     * @param key   property key
     * @param value property value
     */
    void setProperty(@Nonnull InternalTask task, @Nonnull String key, @Nonnull Object value);
}
