Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #10209
This refactors the id and account id to simplify account handling and remove legacy abstractions. It includes removing support for handling multiple account types in backend factories, updating the dependency injection module to use simpler factories, and adapting the codebase to operate directly with account IDs instead of account objects. Several obsolete test and implementation files have been deleted as a result.
Id changes:
Core Architecture Primitives:
BaseIdentifier<T>: A generic abstract base class for all identifiers. It implementsComparable<BaseIdentifier<T>>to support natural sorting in collections and overridesequals/hashCode/toStringto delegate to the underlying value.BaseUuidIdentifier: A specialized base class for identifiers wrapping akotlin.uuid.Uuid.IdentifierFactory<T>: A standardized interface for ID creation and parsing, following a "fail-fast" principle for malformed input.BaseUuidIdentifierFactory<T>: An abstract implementation for UUID-based factories that simplifies the creation of concrete ID factories.Account Module Updates:
AccountId: Now extendsBaseUuidIdentifier, ensuring it is treated as a distinct type from raw UUIDs or other ID types.AccountIdFactory: Refactored to extendBaseUuidIdentifierFactory<AccountId>, centralizing ID generation and parsing logic.UnifiedAccountId: Updated to integrate with the new hierarchy as the sentinel for "all accounts" views.Naming Conventions:
Baseprefix (e.g.,BaseIdentifier,BaseUuidIdentifier,BaseParser).API Cleanup:
.asRaw()method in favor of the standard.toString(), simplifying the API surface while maintaining interoperability with legacy components that require string representations of IDs.Impact
This refactoring improves Java interoperability, prevents accidental ID type mismatches at compile time, and provides a clear, extensible pattern for adding new types of identifiers (e.g.,
Long-based orInt-based IDs) in the future.Refactoring and Simplification:
BaseAccountBackendStorageFactory,BaseAccountImapBackendFactory, andBaseAccountSpecialFolderUpdaterFactoryclasses, along with their associated test files, to eliminate unnecessary abstractions for handling bothLegacyAccountandLegacyAccountDtotypes.FeatureMailModule.ktto use the defaultSpecialFolderUpdater.Factoryand a streamlinedRemoteFolderCreator.Factory, removing references to the deleted factories and simplifying the module configuration.Account Handling Updates:
RemoteFolderCreatorResolverto resolve accounts byAccountIdusing theLegacyAccountManager, and to create IMAP remote folder creators based on account ID rather than account instance.DefaultLegacyAccountManagerto useid.toString()when retrieving account flows, ensuring consistency with account ID handling.Backend:
The backend module defined both
javaandkotlinsource sets, which resulted in incomplete classpath visibility for dependent modules. Downstream Java/Android consumers were only able to access classes from the Kotlin compilation, while classes defined in thejavasource set were not consistently exposed.To address this, all source files have been consolidated into the
javasource set, ensuring a single compilation path and correct visibility for dependent modules.