package com.atlassian.bitbucket.hook;

import com.atlassian.bitbucket.repository.RefChange;
import com.atlassian.bitbucket.repository.Repository;

import javax.annotation.Nonnull;
import java.util.Collection;

/**
 * Factory for {@code HookHandler} that Stash ships with.
 */
public interface BuiltinHookHandlerFactory {

    /**
     * Creates an {@link HookHandler} implementation that delegates to all enabled {@link PreReceiveHook} instances.
     *
     * @param repository the repository
     * @param refChanges the list of refs that are about to updated in the push.
     * @return the callback.
     */
    @Nonnull
    HookHandler preReceive(@Nonnull Repository repository, @Nonnull Collection<RefChange> refChanges);

    /**
     * Creates an {@link HookHandler} implementation that delegates to all enabled {@link PostReceiveHook} instances.
     *
     * @param repository the repository
     * @param refChanges the list of refs that have been updated in the push.
     * @return the callback.
     */
    @Nonnull
    HookHandler postReceive(@Nonnull Repository repository, @Nonnull Collection<RefChange> refChanges);

}
