realm-kotlin
realm-kotlin copied to clipboard
`RealmSet` - basic API
The RealmSet
interface is implemented by unmanaged and managed sets. UnmanagedRealmSet
s implement the interface delegating on mutableSetOf()
. ManagedRealmSet
s are implementing the following:
AbstractMutableSet<E>(), RealmSet<E>
AbstractMutableSet
has defaults for quite a lot of operations from the interface which simplifies the implementation of complex operations needed in the Java SDK, e.g. set intersection with retainAll
(it is implemented using iterator
). These default operations might not be the most efficient as opposed to letting Core do the operation itself, but given that the C-API doesn't expose intersect or union, this seems like the only solution for now.
The trip down to Core is implemented piggybacking on the Converters
written for RealmList
s.
The test framework is inspired by the one used in RealmListTests
with minor changes - it might be worth considering aligning both 🤔
Compiler plugin binding:
- [x] object helpers for regular realms
- [x] object helpers for dynamic realms
RealmSet
interface - in order to have basic testing roundtrip capabilities we need at least these - observe all the other operations are already implemented by AbstractMutableSet
which internally uses iterator()
:
- [x] support for unmanaged sets
- [x] size
- [x] add
- [x] clear
- [x] contains
- [x] iterator
- [x] implement
Deleteable
- [x] flows and changesets
- [x] sync testing
- [x] documentation
- [x] changelog entry
Changes to existing features:
- abstracted operators for collections to become
CollectionOperator
s and piggyback on the existing solution for lists (movedmediator
,realmReference
andconverter
to the new interface) - abstracted notification changesets to be collection-based and not only list-based
- reused changesets from core internally without exposing indices as the public
Set
API doesn't support them but are needed internally to determine which type of changeset to emit - unified subscription to add notification callbacks for collections and objects at interop level (not for results)