diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 4e9f1e7e9..b5f02b964 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -23,10 +23,13 @@ */ package org.kohsuke.github; +import javax.annotation.CheckForNull; import java.io.IOException; import java.net.URL; +import java.util.Arrays; import java.util.Collection; import java.util.Date; +import java.util.List; /** * A pull request. @@ -307,6 +310,28 @@ public class GHPullRequest extends GHIssue { }; } + /** + * @deprecated + * Use {@link #createReview()} + */ + public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, + GHPullRequestReviewComment... comments) throws IOException { + return createReview(body, event, Arrays.asList(comments)); + } + + /** + * @deprecated + * Use {@link #createReview()} + */ + public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, + List comments) throws IOException { + GHPullRequestReviewBuilder b = createReview().body(body); + for (GHPullRequestReviewComment c : comments) { + b.comment(c.getBody(), c.getPath(), c.getPosition()); + } + return b.create(); + } + public GHPullRequestReviewBuilder createReview() { return new GHPullRequestReviewBuilder(this); } diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java b/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java index 811e15a4f..5cda4abb0 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java @@ -47,6 +47,10 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable { private long in_reply_to_id = -1L; + /** + * @deprecated + * You should be using {@link GHPullRequestReviewBuilder#comment(String, String, int)} + */ public static GHPullRequestReviewComment draft(String body, String path, int position) { GHPullRequestReviewComment result = new GHPullRequestReviewComment(); result.body = body; @@ -86,18 +90,17 @@ public class GHPullRequestReviewComment extends GHObject implements Reactable { } @CheckForNull - public Integer getPosition() { - return position == -1 ? null : position; + public int getPosition() { + return position; + } + + public int getOriginalPosition() { + return original_position; } @CheckForNull - public Integer getOriginalPosition() { - return original_position == -1 ? null : original_position; - } - - @CheckForNull - public Long getInReplyToId() { - return in_reply_to_id == -1 ? null : in_reply_to_id; + public long getInReplyToId() { + return in_reply_to_id; } @Override