Class AccountDelta.Builder

java.lang.Object
com.google.gerrit.server.account.AccountDelta.Builder
Enclosing class:
AccountDelta

public abstract static class AccountDelta.Builder extends Object
Class to build an AccountDelta.

Account data is only updated if the corresponding setter is invoked. If a setter is not invoked the corresponding data stays unchanged. To unset string values the setter can be invoked with either null or an empty string (null is converted to an empty string by using the AccountDelta.Builder.WrapperThatConvertsNullStringArgsToEmptyStrings wrapper, see AccountDelta.builder()).

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • setFullName

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setFullName(String fullName)
      Sets a new full name for the account.
      Parameters:
      fullName - the new full name, if null or empty string the full name is unset
    • setDisplayName

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setDisplayName(String displayName)
      Sets a new display name for the account.
      Parameters:
      displayName - the new display name, if null or empty string the display name is unset
    • setPreferredEmail

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setPreferredEmail(String preferredEmail)
      Sets a new preferred email for the account.
      Parameters:
      preferredEmail - the new preferred email, if null or empty string the preferred email is unset
    • setActive

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setActive(boolean active)
      Sets the active flag for the account.
      Parameters:
      active - true if the account should be set to active, false if the account should be set to inactive
    • setStatus

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setStatus(String status)
      Sets a new status for the account.
      Parameters:
      status - the new status, if null or empty string the status is unset
    • addExternalId

      @CanIgnoreReturnValue public AccountDelta.Builder addExternalId(ExternalId extId)
      Adds a new external ID for the account.

      The account ID of the external ID must match the account ID of the account that is updated.

      If an external ID with the same ID already exists the account update will fail with DuplicateExternalIdKeyException.

      Parameters:
      extId - external ID that should be added
      Returns:
      the builder
    • addExternalIds

      @CanIgnoreReturnValue public AccountDelta.Builder addExternalIds(Collection<ExternalId> extIds)
      Adds new external IDs for the account.

      The account IDs of the external IDs must match the account ID of the account that is updated.

      If any of the external ID keys already exists, the insert fails with DuplicateExternalIdKeyException.

      Parameters:
      extIds - external IDs that should be added
      Returns:
      the builder
    • updateExternalId

      @CanIgnoreReturnValue public AccountDelta.Builder updateExternalId(ExternalId extId)
      Updates an external ID for the account.

      The account ID of the external ID must match the account ID of the account that is updated.

      If no external ID with the ID exists the external ID is created.

      Parameters:
      extId - external ID that should be updated
      Returns:
      the builder
    • updateExternalIds

      @CanIgnoreReturnValue public AccountDelta.Builder updateExternalIds(Collection<ExternalId> extIds)
      Updates external IDs for the account.

      The account IDs of the external IDs must match the account ID of the account that is updated.

      If any of the external IDs already exists, it is overwritten. New external IDs are inserted.

      Parameters:
      extIds - external IDs that should be updated
      Returns:
      the builder
    • deleteExternalId

      @CanIgnoreReturnValue public AccountDelta.Builder deleteExternalId(ExternalId extId)
      Deletes an external ID for the account.

      The account ID of the external ID must match the account ID of the account that is updated.

      If no external ID with the ID exists this is a no-op.

      Parameters:
      extId - external ID that should be deleted
      Returns:
      the builder
    • deleteExternalIds

      @CanIgnoreReturnValue public AccountDelta.Builder deleteExternalIds(Collection<ExternalId> extIds)
      Deletes external IDs for the account.

      The account IDs of the external IDs must match the account ID of the account that is updated.

      For non-existing external IDs this is a no-op.

      Parameters:
      extIds - external IDs that should be deleted
      Returns:
      the builder
    • replaceExternalId

      @CanIgnoreReturnValue public AccountDelta.Builder replaceExternalId(ExternalId extIdToDelete, ExternalId extIdToAdd)
      Replaces an external ID.
      Parameters:
      extIdToDelete - external ID that should be deleted
      extIdToAdd - external ID that should be added
      Returns:
      the builder
    • replaceExternalIds

      @CanIgnoreReturnValue public AccountDelta.Builder replaceExternalIds(Collection<ExternalId> extIdsToDelete, Collection<ExternalId> extIdsToAdd)
      Replaces an external IDs.
      Parameters:
      extIdsToDelete - external IDs that should be deleted
      extIdsToAdd - external IDs that should be added
      Returns:
      the builder
    • updateProjectWatch

      @CanIgnoreReturnValue public AccountDelta.Builder updateProjectWatch(ProjectWatches.ProjectWatchKey projectWatchKey, Set<NotifyConfig.NotifyType> notifyTypes)
      Updates a project watch for the account.

      If no project watch with the key exists the project watch is created.

      Parameters:
      projectWatchKey - key of the project watch that should be updated
      notifyTypes - the notify types that should be set for the project watch
      Returns:
      the builder
    • updateProjectWatches

      @CanIgnoreReturnValue public AccountDelta.Builder updateProjectWatches(Map<ProjectWatches.ProjectWatchKey,Set<NotifyConfig.NotifyType>> projectWatches)
      Updates project watches for the account.

      If any of the project watches already exists, it is overwritten. New project watches are inserted.

      Parameters:
      projectWatches - project watches that should be updated
      Returns:
      the builder
    • deleteProjectWatch

      @CanIgnoreReturnValue public AccountDelta.Builder deleteProjectWatch(ProjectWatches.ProjectWatchKey projectWatch)
      Deletes a project watch for the account.

      If no project watch with the ID exists this is a no-op.

      Parameters:
      projectWatch - project watch that should be deleted
      Returns:
      the builder
    • deleteProjectWatches

      @CanIgnoreReturnValue public AccountDelta.Builder deleteProjectWatches(Collection<ProjectWatches.ProjectWatchKey> projectWatches)
      Deletes project watches for the account.

      For non-existing project watches this is a no-op.

      Parameters:
      projectWatches - project watches that should be deleted
      Returns:
      the builder
    • setGeneralPreferences

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setGeneralPreferences(GeneralPreferencesInfo generalPreferences)
      Sets the general preferences for the account.

      Updates any preference that is non-null in the provided GeneralPreferencesInfo.

      Parameters:
      generalPreferences - the general preferences that should be set
      Returns:
      the builder
    • setDiffPreferences

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setDiffPreferences(DiffPreferencesInfo diffPreferences)
      Sets the diff preferences for the account.

      Updates any preference that is non-null in the provided DiffPreferencesInfo.

      Parameters:
      diffPreferences - the diff preferences that should be set
      Returns:
      the builder
    • setEditPreferences

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setEditPreferences(EditPreferencesInfo editPreferences)
      Sets the edit preferences for the account.

      Updates any preference that is non-null in the provided EditPreferencesInfo.

      Parameters:
      editPreferences - the edit preferences that should be set
      Returns:
      the builder
    • setShouldDeleteAccount

      @CanIgnoreReturnValue public abstract AccountDelta.Builder setShouldDeleteAccount(boolean shouldDelete)
    • deleteAccount

      @CanIgnoreReturnValue public AccountDelta.Builder deleteAccount(Collection<ExternalId> extIdsToDelete)
      Builds an AccountDelta that deletes all data.
      Parameters:
      extIdsToDelete - external IDs that should be deleted
      Returns:
      the builder
    • build

      public abstract AccountDelta build()
      Builds the instance.