package com.atlassian.stash.internal.web.soy.functions.nav;

import com.atlassian.soy.renderer.JsExpression;
import com.atlassian.bitbucket.comment.Comment;
import com.atlassian.bitbucket.nav.NavBuilder;

public class PullRequestCommentNavFunction extends BasePullRequestNavFunction {
    public PullRequestCommentNavFunction(NavBuilder navBuilder) {
        super(navBuilder, "nav_pull_comment", 4);
    }

    @Override
    protected JsNavBuilder initJsBuilder(JsExpression... jsExpressions) {
        return pullRequest(jsExpressions).overview().comment(jsExpressions[3]).withParamsIfAvailable(jsExpressions, 3);
    }

    @Override
    protected NavBuilder.Builder initBuilder(Object... args) {
        if (args[3] instanceof Comment) {
            return pullRequest(args).comment(((Comment) args[3]).getId());
        } else {
            return pullRequest(args).comment(((Number) args[3]).longValue());
        }
    }
}
