package com.atlassian.bitbucket.internal.importer.repository;

import com.atlassian.bitbucket.event.repository.AbstractRepositoryRefsChangedEvent;
import com.atlassian.bitbucket.repository.MinimalRef;
import com.atlassian.bitbucket.repository.RefChange;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.event.api.AsynchronousPreferred;

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

import static java.util.Objects.requireNonNull;

@AsynchronousPreferred
public class RepositoryImportedEvent extends AbstractRepositoryRefsChangedEvent {

    private final Collection<MinimalRef> failedRefs;
    private final String sourceUrl;

    public RepositoryImportedEvent(@Nonnull Object source, @Nonnull Repository repository,
                                   @Nonnull Collection<RefChange> refChanges,
                                   @Nonnull Collection<MinimalRef> failedRefs,
                                   @Nonnull String sourceUrl) {
        super(source, repository, refChanges);

        this.failedRefs = requireNonNull(failedRefs, "failedRefs");
        this.sourceUrl = requireNonNull(sourceUrl, "sourceUrl");
    }

    @Nonnull
    public Collection<MinimalRef> getFailedRefs() {
        return failedRefs;
    }

    @Nonnull
    public String getSourceUrl() {
        return sourceUrl;
    }
}
