Unified various different instances of the "author" class

This commit is contained in:
Kohsuke Kawaguchi
2013-11-12 12:10:33 -08:00
parent 7536eeea54
commit 930a582afa
4 changed files with 70 additions and 55 deletions

View File

@@ -1,11 +1,12 @@
package org.kohsuke.github;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import java.io.IOException;
import java.net.URL;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
@@ -31,11 +32,13 @@ public class GHCommit {
private int comment_count;
public GHAuthor getAuthor() {
@WithBridgeMethods(value=GHAuthor.class,castRequired=true)
public GitUser getAuthor() {
return author;
}
public GHAuthor getCommitter() {
@WithBridgeMethods(value=GHAuthor.class,castRequired=true)
public GitUser getCommitter() {
return committer;
}
@@ -50,21 +53,11 @@ public class GHCommit {
return comment_count;
}
}
public static class GHAuthor {
private String name,email,date;
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public Date getDate() {
return GitHub.parseDate(date);
}
/**
* @deprecated Use {@link GitUser} instead.
*/
public static class GHAuthor extends GitUser {
}
public static class Stats {

View File

@@ -1,5 +1,7 @@
package org.kohsuke.github;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import java.net.URL;
import java.util.Date;
@@ -109,11 +111,13 @@ public class GHCompare {
return message;
}
public User getAuthor() {
@WithBridgeMethods(value=User.class,castRequired=true)
public GitUser getAuthor() {
return author;
}
public User getCommitter() {
@WithBridgeMethods(value=User.class,castRequired=true)
public GitUser getCommitter() {
return committer;
}
@@ -134,23 +138,13 @@ public class GHCompare {
}
}
public static class User {
private String name, email, date;
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public Date getDate() {
return GitHub.parseDate(date);
}
/**
* @deprecated use {@link GitUser} instead.
*/
public static class User extends GitUser {
}
public static enum Status {
behind, ahead, identical;
behind, ahead, identical
}
}

View File

@@ -23,8 +23,9 @@
*/
package org.kohsuke.github;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import java.net.URL;
import java.util.Date;
/**
* Commit detail inside a {@link GHPullRequest}.
@@ -33,25 +34,12 @@ import java.util.Date;
*/
public class GHPullRequestCommitDetail {
public static class Authorship {
String name;
String email;
String date;
/**
* @deprecated Use {@link GitUser}
*/
public static class Authorship extends GitUser {}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public Date getDate() {
return GitHub.parseDate(date);
}
}
public static class Tree {
public static class Tree {
String sha;
String url;
@@ -72,11 +60,13 @@ public class GHPullRequestCommitDetail {
String url;
int comment_count;
public Authorship getAuthor() {
@WithBridgeMethods(value=Authorship.class,castRequired=true)
public GitUser getAuthor() {
return author;
}
public Authorship getCommitter() {
@WithBridgeMethods(value=Authorship.class,castRequired=true)
public GitUser getCommitter() {
return committer;
}

View File

@@ -0,0 +1,38 @@
package org.kohsuke.github;
import java.util.Date;
/**
* Represents a user in Git who authors/commits a commit.
*
* In contrast, {@link GHUser} is an user of GitHub. Because Git allows a person to
* use multiple e-mail addresses and names when creating a commit, there's generally
* no meaningful mapping between {@link GHUser} and {@link GitUser}.
*
* @author Kohsuke Kawaguchi
*/
public class GitUser {
private String name, email, date;
/**
* Human readable name of the user, such as "Kohsuke Kawaguchi"
*/
public String getName() {
return name;
}
/**
* E-mail address, such as "foo@example.com"
*/
public String getEmail() {
return email;
}
/**
* This field doesn't appear to be consistently available in all the situations where this class
* is used.
*/
public Date getDate() {
return GitHub.parseDate(date);
}
}