CurrentUser#getUserName: Return Optional<String> instead of nullable String

This makes it more explicit that callers must handle the case where the
returned username is absent.

Change-Id: I97e33caa8e9cc8092dc398e3b383d7afd5beb96f
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-19 11:57:01 +01:00
parent d59a61dde5
commit ef120cd66d
21 changed files with 67 additions and 81 deletions

View File

@@ -19,6 +19,7 @@ import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.inject.servlet.RequestScoped;
import java.util.Optional;
import java.util.function.Consumer;
/**
@@ -90,8 +91,8 @@ public abstract class CurrentUser {
public abstract GroupMembership getEffectiveGroups();
/** Unique name of the user on this server, if one has been assigned. */
public String getUserName() {
return null;
public Optional<String> getUserName() {
return Optional.empty();
}
/** Check if user is the IdentifiedUser */