OutgoingEmail: Annotate methods with @Nullable
The getNameFor, getNameEmailFor and getUserNameEmailFor may take a null accountId and handle it accordingly. Annotate the accountId parameters as @Nullable. Additionally, getUserNameEmailFor may return null if the accountId is null, so annotate that as @Nullable too. Change-Id: I383efdcd799568253ab4d4425c43480bb67b744a
This commit is contained in:
@@ -21,6 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
@@ -347,7 +348,7 @@ public abstract class OutgoingEmail {
|
||||
* @param accountId user to fetch.
|
||||
* @return name of the account, or the server identity name if null.
|
||||
*/
|
||||
protected String getNameFor(final Account.Id accountId) {
|
||||
protected String getNameFor(@Nullable Account.Id accountId) {
|
||||
if (accountId == null) {
|
||||
return args.gerritPersonIdent.getName();
|
||||
}
|
||||
@@ -361,7 +362,7 @@ public abstract class OutgoingEmail {
|
||||
* @param accountId user to fetch.
|
||||
* @return name/email of account; Anonymous Coward if unset or the server identity if null.
|
||||
*/
|
||||
public String getNameEmailFor(Account.Id accountId) {
|
||||
public String getNameEmailFor(@Nullable Account.Id accountId) {
|
||||
if (accountId == null) {
|
||||
return String.format(
|
||||
"%s <%s>", args.gerritPersonIdent.getName(), args.gerritPersonIdent.getEmailAddress());
|
||||
@@ -377,7 +378,8 @@ public abstract class OutgoingEmail {
|
||||
* @param accountId user to fetch.
|
||||
* @return name/email of account, username, or null if unset.
|
||||
*/
|
||||
public String getUserNameEmailFor(Account.Id accountId) {
|
||||
@Nullable
|
||||
public String getUserNameEmailFor(@Nullable Account.Id accountId) {
|
||||
if (accountId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user