diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountInfo.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountInfo.java
index 8614be5fdf..e8f9fd591c 100644
--- a/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountInfo.java
+++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/AccountInfo.java
@@ -76,51 +76,4 @@ public class AccountInfo {
public String getUsername() {
return username;
}
-
- /**
- * Formats an account name.
- *
- * If the account has a full name, it returns only the full name. Otherwise it
- * returns a longer form that includes the email address.
- */
- public String getName(String anonymousCowardName) {
- if (getFullName() != null) {
- return getFullName();
- }
- if (getPreferredEmail() != null) {
- return getPreferredEmail();
- }
- return getNameEmail(anonymousCowardName);
- }
-
- /**
- * Formats an account as a name and an email address.
- *
- * Example output:
- *
- * - {@code A U. Thor <author@example.com>}: full populated
- * - {@code A U. Thor (12)}: missing email address
- * - {@code Anonymous Coward <author@example.com>}: missing name
- * - {@code Anonymous Coward (12)}: missing name and email address
- *
- */
- public String getNameEmail(String anonymousCowardName) {
- String name = getFullName();
- if (name == null) {
- name = anonymousCowardName;
- }
-
- final StringBuilder b = new StringBuilder();
- b.append(name);
- if (getPreferredEmail() != null) {
- b.append(" <");
- b.append(getPreferredEmail());
- b.append(">");
- } else if (getId() != null) {
- b.append(" (");
- b.append(getId().get());
- b.append(")");
- }
- return b.toString();
- }
}
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java
index 295239f905..2bb67023b6 100644
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java
+++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/Account.java
@@ -243,6 +243,49 @@ public final class Account {
preferredEmail = addr;
}
+ /**
+ * Formats an account name.
+ *
+ * If the account has a full name, it returns only the full name. Otherwise it
+ * returns a longer form that includes the email address.
+ */
+ public String getName(String anonymousCowardName) {
+ if (fullName != null) {
+ return fullName;
+ }
+ if (preferredEmail != null) {
+ return preferredEmail;
+ }
+ return getNameEmail(anonymousCowardName);
+ }
+
+ /**
+ * Get the name and email address.
+ *
+ * Example output:
+ *
+ * - {@code A U. Thor <author@example.com>}: full populated
+ * - {@code A U. Thor (12)}: missing email address
+ * - {@code Anonymous Coward <author@example.com>}: missing name
+ * - {@code Anonymous Coward (12)}: missing name and email address
+ *
+ */
+ public String getNameEmail(String anonymousCowardName) {
+ String name = fullName != null ? fullName : anonymousCowardName;
+ StringBuilder b = new StringBuilder();
+ b.append(name);
+ if (preferredEmail != null) {
+ b.append(" <");
+ b.append(preferredEmail);
+ b.append(">");
+ } else if (accountId != null) {
+ b.append(" (");
+ b.append(accountId.get());
+ b.append(")");
+ }
+ return b.toString();
+ }
+
/** Get the date and time the user first registered. */
public Timestamp getRegisteredOn() {
return registeredOn;
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java b/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java
index e9f37e96fd..2e93ce738b 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java
@@ -18,7 +18,6 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
-import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
import com.google.gerrit.reviewdb.client.Change;
@@ -309,7 +308,7 @@ public class IdentifiedUser extends CurrentUser {
}
public String getNameEmail() {
- return new AccountInfo(getAccount()).getNameEmail(anonymousCowardName);
+ return getAccount().getNameEmail(anonymousCowardName);
}
@Override
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java
index 3199a47376..f6f7dd5e8b 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java
@@ -16,7 +16,6 @@ package com.google.gerrit.server.notedb;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Ints;
-import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.RefNames;
@@ -62,7 +61,7 @@ public class ChangeNoteUtil {
public static PersonIdent newIdent(Account author, Date when,
PersonIdent serverIdent, String anonymousCowardName) {
return new PersonIdent(
- new AccountInfo(author).getName(anonymousCowardName),
+ author.getName(anonymousCowardName),
author.getId().get() + "@" + GERRIT_PLACEHOLDER_HOST,
when, serverIdent.getTimeZone());
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/CommentsInNotesUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/CommentsInNotesUtil.java
index a35e7b9b85..b59386bbef 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/notedb/CommentsInNotesUtil.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/notedb/CommentsInNotesUtil.java
@@ -26,7 +26,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.primitives.Ints;
-import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.CommentRange;
@@ -364,7 +363,7 @@ public class CommentsInNotesUtil {
private PersonIdent newIdent(Account author, Date when) {
return new PersonIdent(
- new AccountInfo(author).getName(anonymousCowardName),
+ author.getName(anonymousCowardName),
author.getId().get() + "@" + GERRIT_PLACEHOLDER_HOST,
when, serverIdent.getTimeZone());
}