package com.atlassian.stash.internal.scm.git.pull.task;

import com.atlassian.bitbucket.pull.PullRequest;

import javax.annotation.Nonnull;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * @since 3.4
 */
public abstract class AbstractPullRequestTask implements PullRequestTask {

    private static final long serialVersionUID = 1L;

    private final long pullRequestId;
    private final int repositoryId;

    protected AbstractPullRequestTask(@Nonnull PullRequest pullRequest) {
        pullRequestId = checkNotNull(pullRequest, "pullRequest").getId();
        repositoryId = pullRequest.getToRef().getRepository().getId();
    }

    @Override
    public long getPullRequestId() {
        return pullRequestId;
    }

    @Override
    public int getRepositoryId() {
        return repositoryId;
    }
}
