Class AccountState

java.lang.Object
com.google.gerrit.server.account.AccountState

public abstract class AccountState extends Object
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 Details

    • AccountState

      public AccountState()
  • Method Details

    • forAccount

      public static AccountState forAccount(Account account)
      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

      public static AccountState forAccount(Account account, Collection<ExternalId> extIds)
      Creates an AccountState for a given account with no project watches and default preferences.
      Parameters:
      account - the account
      extIds - 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

      public abstract Account account()
      Get the cached account metadata.
    • externalIds

      public abstract com.google.common.collect.ImmutableSet<ExternalId> externalIds()
      The external identities that identify the account holder.
    • userName

      public abstract Optional<String> userName()
      Get the username, if one has been declared for this user.

      The username is the ExternalId using the scheme ExternalId.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

      public GeneralPreferencesInfo generalPreferences()
      The general preferences of the account.
    • diffPreferences

      public DiffPreferencesInfo diffPreferences()
      The diff preferences of the account.
    • editPreferences

      public EditPreferencesInfo editPreferences()
      The edit preferences of the account.
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • debugString

      public final String debugString()
    • defaultPreferences

      public abstract Optional<CachedPreferences> defaultPreferences()
      Gerrit's default preferences as stored in preferences.config.
    • userPreferences

      public abstract Optional<CachedPreferences> userPreferences()
      User preferences as stored in preferences.config.