mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 08:21:23 +00:00
Add JavaDocs
Do using IntelliJ JavaDocs plugin. Better to have something than nothing.
This commit is contained in:
@@ -45,8 +45,8 @@ import java.util.Set;
|
||||
*
|
||||
* @author Eric Maupin
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see GHRepository#getIssue(int)
|
||||
* @see GitHub#searchIssues()
|
||||
* @see GHRepository#getIssue(int) GHRepository#getIssue(int)
|
||||
* @see GitHub#searchIssues() GitHub#searchIssues()
|
||||
* @see GHIssueSearchBuilder
|
||||
*/
|
||||
public class GHIssue extends GHObject implements Reactable {
|
||||
@@ -74,6 +74,8 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
protected boolean locked;
|
||||
|
||||
/**
|
||||
* The type Label.
|
||||
*
|
||||
* @deprecated use {@link GHLabel}
|
||||
*/
|
||||
public static class Label extends GHLabel {
|
||||
@@ -107,6 +109,8 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Repository to which the issue belongs.
|
||||
*
|
||||
* @return the repository
|
||||
*/
|
||||
public GHRepository getRepository() {
|
||||
return owner;
|
||||
@@ -114,6 +118,8 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* The description of this pull request.
|
||||
*
|
||||
* @return the body
|
||||
*/
|
||||
public String getBody() {
|
||||
return body;
|
||||
@@ -121,6 +127,8 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @return the number
|
||||
*/
|
||||
public int getNumber() {
|
||||
return number;
|
||||
@@ -133,18 +141,40 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
return GitHub.parseURL(html_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets title.
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is locked boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets state.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public GHIssueState getState() {
|
||||
return Enum.valueOf(GHIssueState.class, state.toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets labels.
|
||||
*
|
||||
* @return the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public Collection<GHLabel> getLabels() throws IOException {
|
||||
if (labels == null) {
|
||||
return Collections.emptyList();
|
||||
@@ -152,18 +182,40 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
return Collections.<GHLabel> unmodifiableList(labels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets closed at.
|
||||
*
|
||||
* @return the closed at
|
||||
*/
|
||||
public Date getClosedAt() {
|
||||
return GitHub.parseDate(closed_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets api url.
|
||||
*
|
||||
* @return the api url
|
||||
*/
|
||||
public URL getApiURL() {
|
||||
return GitHub.parseURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void lock() throws IOException {
|
||||
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void unlock() throws IOException {
|
||||
new Requester(root).method("PUT").to(getApiRoute() + "/lock");
|
||||
}
|
||||
@@ -171,7 +223,11 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
/**
|
||||
* Updates the issue by adding a comment.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @return Newly posted comment.
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
@WithBridgeMethods(void.class)
|
||||
public GHIssueComment comment(String message) throws IOException {
|
||||
@@ -190,6 +246,9 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Closes this issue.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
edit("state", "closed");
|
||||
@@ -197,27 +256,70 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Reopens this issue.
|
||||
*
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void reopen() throws IOException {
|
||||
edit("state", "open");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets title.
|
||||
*
|
||||
* @param title
|
||||
* the title
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setTitle(String title) throws IOException {
|
||||
edit("title", title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets body.
|
||||
*
|
||||
* @param body
|
||||
* the body
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setBody(String body) throws IOException {
|
||||
edit("body", body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets milestone.
|
||||
*
|
||||
* @param milestone
|
||||
* the milestone
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setMilestone(GHMilestone milestone) throws IOException {
|
||||
edit("milestone", milestone.getNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign to.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void assignTo(GHUser user) throws IOException {
|
||||
setAssignees(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setLabels(String... labels) throws IOException {
|
||||
editIssue("labels", labels);
|
||||
}
|
||||
@@ -227,15 +329,33 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
*
|
||||
* @param names
|
||||
* Names of the label
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addLabels(String... names) throws IOException {
|
||||
_addLabels(Arrays.asList(names));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addLabels(GHLabel... labels) throws IOException {
|
||||
addLabels(Arrays.asList(labels));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addLabels(Collection<GHLabel> labels) throws IOException {
|
||||
_addLabels(GHLabel.toNames(labels));
|
||||
}
|
||||
@@ -256,18 +376,37 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Remove a given label by name from this issue.
|
||||
*
|
||||
* @param names
|
||||
* the names
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeLabels(String... names) throws IOException {
|
||||
_removeLabels(Arrays.asList(names));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #removeLabels(String...)
|
||||
* Remove labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see #removeLabels(String...) #removeLabels(String...)
|
||||
*/
|
||||
public void removeLabels(GHLabel... labels) throws IOException {
|
||||
removeLabels(Arrays.asList(labels));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove labels.
|
||||
*
|
||||
* @param labels
|
||||
* the labels
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeLabels(Collection<GHLabel> labels) throws IOException {
|
||||
_removeLabels(GHLabel.toNames(labels));
|
||||
}
|
||||
@@ -287,7 +426,10 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
/**
|
||||
* Obtains all the comments associated with this issue.
|
||||
*
|
||||
* @see #listComments()
|
||||
* @return the comments
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
* @see #listComments() #listComments()
|
||||
*/
|
||||
public List<GHIssueComment> getComments() throws IOException {
|
||||
return listComments().asList();
|
||||
@@ -295,6 +437,10 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Obtains all the comments associated with this issue.
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHIssueComment> listComments() throws IOException {
|
||||
return root.retrieve().asPagedIterable(getIssuesApiRoute() + "/comments", GHIssueComment[].class,
|
||||
@@ -315,49 +461,123 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
GHReaction[].class, item -> item.wrap(owner.root));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addAssignees(GHUser... assignees) throws IOException {
|
||||
addAssignees(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void addAssignees(Collection<GHUser> assignees) throws IOException {
|
||||
root.retrieve().method("POST").withLogins(ASSIGNEES, assignees).to(getIssuesApiRoute() + "/assignees", this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setAssignees(GHUser... assignees) throws IOException {
|
||||
setAssignees(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void setAssignees(Collection<GHUser> assignees) throws IOException {
|
||||
new Requester(root).withLogins(ASSIGNEES, assignees).method("PATCH").to(getIssuesApiRoute());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeAssignees(GHUser... assignees) throws IOException {
|
||||
removeAssignees(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove assignees.
|
||||
*
|
||||
* @param assignees
|
||||
* the assignees
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public void removeAssignees(Collection<GHUser> assignees) throws IOException {
|
||||
root.retrieve().method("DELETE").withLogins(ASSIGNEES, assignees).inBody()
|
||||
.to(getIssuesApiRoute() + "/assignees", this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets api route.
|
||||
*
|
||||
* @return the api route
|
||||
*/
|
||||
protected String getApiRoute() {
|
||||
return getIssuesApiRoute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets issues api route.
|
||||
*
|
||||
* @return the issues api route
|
||||
*/
|
||||
protected String getIssuesApiRoute() {
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/issues/" + number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets assignee.
|
||||
*
|
||||
* @return the assignee
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getAssignee() throws IOException {
|
||||
return root.intern(assignee);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets assignees.
|
||||
*
|
||||
* @return the assignees
|
||||
*/
|
||||
public List<GHUser> getAssignees() {
|
||||
return Collections.unmodifiableList(Arrays.asList(assignees));
|
||||
}
|
||||
|
||||
/**
|
||||
* User who submitted the issue.
|
||||
*
|
||||
* @return the user
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getUser() throws IOException {
|
||||
return root.intern(user);
|
||||
@@ -369,6 +589,10 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
* <p>
|
||||
* Note that GitHub doesn't always seem to report this information even for an issue that's already closed. See
|
||||
* https://github.com/kohsuke/github-api/issues/60.
|
||||
*
|
||||
* @return the closed by
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public GHUser getClosedBy() throws IOException {
|
||||
if (!"closed".equals(state))
|
||||
@@ -381,38 +605,73 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
return root.intern(closed_by);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets comments count.
|
||||
*
|
||||
* @return the comments count
|
||||
*/
|
||||
public int getCommentsCount() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns non-null if this issue is a shadow of a pull request.
|
||||
*
|
||||
* @return the pull request
|
||||
*/
|
||||
public PullRequest getPullRequest() {
|
||||
return pull_request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is pull request boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean isPullRequest() {
|
||||
return pull_request != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets milestone.
|
||||
*
|
||||
* @return the milestone
|
||||
*/
|
||||
public GHMilestone getMilestone() {
|
||||
return milestone;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type PullRequest.
|
||||
*/
|
||||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD",
|
||||
"UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
|
||||
public static class PullRequest {
|
||||
private String diff_url, patch_url, html_url;
|
||||
|
||||
/**
|
||||
* Gets diff url.
|
||||
*
|
||||
* @return the diff url
|
||||
*/
|
||||
public URL getDiffUrl() {
|
||||
return GitHub.parseURL(diff_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets patch url.
|
||||
*
|
||||
* @return the patch url
|
||||
*/
|
||||
public URL getPatchUrl() {
|
||||
return GitHub.parseURL(patch_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public URL getUrl() {
|
||||
return GitHub.parseURL(html_url);
|
||||
}
|
||||
@@ -420,6 +679,10 @@ public class GHIssue extends GHObject implements Reactable {
|
||||
|
||||
/**
|
||||
* Lists events for this issue. See https://developer.github.com/v3/issues/events/
|
||||
*
|
||||
* @return the paged iterable
|
||||
* @throws IOException
|
||||
* the io exception
|
||||
*/
|
||||
public PagedIterable<GHIssueEvent> listEvents() throws IOException {
|
||||
return root.retrieve().asPagedIterable(owner.getApiTailUrl(String.format("/issues/%s/events", number)),
|
||||
|
||||
Reference in New Issue
Block a user