Skip to content

Commit

Permalink
Added getters for the objects notifications refer to
Browse files Browse the repository at this point in the history
  • Loading branch information
syniuhin committed Apr 8, 2015
1 parent 277ccb5 commit b058c39
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/org/kohsuke/github/GHThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ public String getType() {
return subject.type;
}

public GHIssue getBoundIssue() throws IOException {
if (!"Issue".equals(subject.type))
throw new IllegalStateException("Notification doesn't point to Issue");
return repository.getIssue(
Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1)));
}

public GHPullRequest getBoundPullRequest() throws IOException {
if (!"PullRequest".equals(subject.type))
throw new IllegalStateException("Notification doesn't point to PullRequest");
return repository.getPullRequest(
Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1)));
}

public GHCommit getBoundCommit() throws IOException {
if (!"Commit".equals(subject.type))
throw new IllegalStateException("Notification doesn't point to Commit");
return repository.getCommit(subject.url.substring(subject.url.lastIndexOf('/') + 1));
}

/*package*/ GHThread wrap(GitHub root) {
this.root = root;
if (this.repository!=null)
Expand Down

0 comments on commit b058c39

Please sign in to comment.