-
Notifications
You must be signed in to change notification settings - Fork 711
/
GHIssueCommentQueryBuilder.java
61 lines (55 loc) · 1.7 KB
/
GHIssueCommentQueryBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.kohsuke.github;
import java.util.Date;
/**
* Builds a query for listing comments on an issue.
* <p>
* Call various methods that set the filter criteria, then the {@link #list()} method to actually retrieve the comments.
*
* <pre>
* GHIssue issue = ...;
* for (GHIssueComment comment : issue.queryComments().since(x).list()) {
* ...
* }
* </pre>
*
* @author Yoann Rodiere
* @see GHIssue#queryComments() GHIssue#queryComments()
* @see <a href="https://docs.github.com/en/rest/issues/comments#list-issue-comments">List issue comments</a>
*/
public class GHIssueCommentQueryBuilder {
private final Requester req;
private final GHIssue issue;
GHIssueCommentQueryBuilder(GHIssue issue) {
this.issue = issue;
this.req = issue.root().createRequest().withUrlPath(issue.getIssuesApiRoute() + "/comments");
}
/**
* Only comments created/updated after this date will be returned.
*
* @param date
* the date
* @return the query builder
*/
public GHIssueCommentQueryBuilder since(Date date) {
req.with("since", GitHubClient.printDate(date));
return this;
}
/**
* Only comments created/updated after this timestamp will be returned.
*
* @param timestamp
* the timestamp
* @return the query builder
*/
public GHIssueCommentQueryBuilder since(long timestamp) {
return since(new Date(timestamp));
}
/**
* Lists up the comments with the criteria added so far.
*
* @return the paged iterable
*/
public PagedIterable<GHIssueComment> list() {
return req.toIterable(GHIssueComment[].class, item -> item.wrapUp(issue));
}
}