Package com.google.gerrit.server.account
Class AccountState
java.lang.Object
com.google.gerrit.server.account.AccountState
Superset of all information related to an Account. This includes external IDs, project watches,
and properties from the account config file. AccountState maps one-to-one to Account.
Most callers should not construct AccountStates directly but rather lookup accounts via the
account cache (see AccountCache.get(Account.Id)
).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Account
account()
Get the cached account metadata.final String
abstract Optional
<CachedPreferences> Gerrit's default preferences as stored inpreferences.config
.The diff preferences of the account.The edit preferences of the account.abstract com.google.common.collect.ImmutableSet
<ExternalId> The external identities that identify the account holder.static AccountState
forAccount
(Account account) Creates an AccountState for a given account with no external IDs, no project watches and default preferences.static AccountState
forAccount
(Account account, Collection<ExternalId> extIds) Creates an AccountState for a given account with no project watches and default preferences.static AccountState
forCachedAccount
(CachedAccountDetails account, CachedPreferences defaultConfig, ExternalIds externalIds) Creates an AccountState for a given account and external IDs.The general preferences of the account.abstract com.google.common.collect.ImmutableMap
<ProjectWatchKey, com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>> The project watches of the account.final String
toString()
userName()
Get the username, if one has been declared for this user.abstract Optional
<CachedPreferences> User preferences as stored inpreferences.config
.static AccountState
withState
(Account account, com.google.common.collect.ImmutableSet<ExternalId> externalIds, Optional<String> userName, com.google.common.collect.ImmutableMap<ProjectWatchKey, com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>> projectWatches, Optional<CachedPreferences> defaultPreferences, Optional<CachedPreferences> userPreferences) Creates an AccountState instance containing the given data.
-
Constructor Details
-
AccountState
public AccountState()
-
-
Method Details
-
forAccount
Creates an AccountState for a given account with no external IDs, no project watches and default preferences.- Parameters:
account
- the account- Returns:
- the account state
-
forCachedAccount
public static AccountState forCachedAccount(CachedAccountDetails account, CachedPreferences defaultConfig, ExternalIds externalIds) throws IOException Creates an AccountState for a given account and external IDs.- Parameters:
account
- the account- Returns:
- the account state
- Throws:
IOException
-
forAccount
Creates an AccountState for a given account with no project watches and default preferences.- Parameters:
account
- the accountextIds
- the external IDs- Returns:
- the account state
-
withState
public static AccountState withState(Account account, com.google.common.collect.ImmutableSet<ExternalId> externalIds, Optional<String> userName, com.google.common.collect.ImmutableMap<ProjectWatchKey, com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>> projectWatches, Optional<CachedPreferences> defaultPreferences, Optional<CachedPreferences> userPreferences) Creates an AccountState instance containing the given data. -
account
Get the cached account metadata. -
externalIds
The external identities that identify the account holder. -
userName
Get the username, if one has been declared for this user.The username is the
ExternalId
using the schemeExternalId.SCHEME_USERNAME
.- Returns:
- the username,
Optional.empty()
if the user has no username, or if the username is empty
-
projectWatches
public abstract com.google.common.collect.ImmutableMap<ProjectWatchKey,com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>> projectWatches()The project watches of the account. -
generalPreferences
The general preferences of the account. -
diffPreferences
The diff preferences of the account. -
editPreferences
The edit preferences of the account. -
toString
-
debugString
-
defaultPreferences
Gerrit's default preferences as stored inpreferences.config
. -
userPreferences
User preferences as stored inpreferences.config
.
-