package com.atlassian.bitbucket.notification.pull;

import com.atlassian.bitbucket.pull.PullRequest;
import com.atlassian.bitbucket.user.ApplicationUser;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Date;

import static java.util.Objects.requireNonNull;

/**
 * Notification for when a Pull Request source ref is updated due to a push to the source ref.
 */
public class PullRequestFromRefRescopedNotification extends AbstractPullRequestNotification {

    private final String previousFromHash;
    private final String previousToHash;

    public PullRequestFromRefRescopedNotification(@Nonnull PullRequest pullRequest,
                                                  @Nonnull Date whenActivityPerformed,
                                                  @Nullable ApplicationUser activityPerformer,
                                                  @Nonnull String previousFromHash,
                                                  @Nonnull String previousToHash) {
        super(pullRequest, whenActivityPerformed, activityPerformer);
        this.previousFromHash = requireNonNull(previousFromHash, "previousFromHash");
        this.previousToHash = requireNonNull(previousToHash, "previousToHash");
    }

    @Nonnull
    public String getPreviousFromHash() {
        return previousFromHash;
    }

    @Nonnull
    public String getPreviousToHash() {
        return previousToHash;
    }

    @Override
    public String toString() {
        return "PullRequestPushedNotification{" +
                super.toString() +
                '}';
    }

}
