package com.atlassian.bitbucket.event.branch;

import com.atlassian.bitbucket.event.repository.AbstractRepositoryRefsChangedEvent;
import com.atlassian.bitbucket.repository.Branch;
import com.atlassian.bitbucket.repository.RefChange;
import com.atlassian.bitbucket.repository.Repository;

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

/**
 * Base event for any operations on branches.
 *
 * @see BranchCreatedEvent
 * @see BranchDeletedEvent
 */
public abstract class BranchChangedEvent extends AbstractRepositoryRefsChangedEvent {

    protected final Branch branch;

    protected BranchChangedEvent(@Nonnull Object source, @Nonnull Repository repository, @Nonnull Branch branch,
                                 @Nonnull RefChange refChange) {
        super(source, repository, Collections.singleton(refChange));
        this.branch = branch;
    }

    @Nonnull
    public Branch getBranch() {
        return branch;
    }
}
