CommitInfo: Use ToStringHelper
This extension class is not used by the UI and so can have a Guava dependency. Upon further consideration, using the raw JGit commit format wouldn't provide any benefit here, as the string is just for debugging. Change-Id: Iaef50fb95b7d747aaddbbabf034ad41296490f80
This commit is contained in:
@@ -16,6 +16,8 @@ package com.google.gerrit.extensions.common;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -50,19 +52,18 @@ public class CommitInfo {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Using something like the raw commit format might be nice, but we can't depend on JGit here.
|
||||
StringBuilder sb = new StringBuilder().append(getClass().getSimpleName()).append('{');
|
||||
sb.append(commit);
|
||||
ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(commit);
|
||||
if (parents != null) {
|
||||
sb.append(", parents=").append(parents.stream().map(p -> p.commit).collect(joining(", ")));
|
||||
helper.add("parents", parents.stream().map(p -> p.commit).collect(joining(", ")));
|
||||
}
|
||||
sb.append(", author=").append(author);
|
||||
sb.append(", committer=").append(committer);
|
||||
sb.append(", subject=").append(subject);
|
||||
sb.append(", message=").append(message);
|
||||
helper
|
||||
.add("author", author)
|
||||
.add("committer", committer)
|
||||
.add("subject", subject)
|
||||
.add("message", message);
|
||||
if (webLinks != null) {
|
||||
sb.append(", webLinks=").append(webLinks);
|
||||
helper.add("webLinks", webLinks);
|
||||
}
|
||||
return sb.append('}').toString();
|
||||
return helper.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user