Skip to content

Support Primitive List feature#5031

Merged
cmelchior merged 249 commits intomasterfrom
feature/primitive_list
Oct 1, 2017
Merged

Support Primitive List feature#5031
cmelchior merged 249 commits intomasterfrom
feature/primitive_list

Conversation

@zaki50
Copy link
Copy Markdown
Contributor

@zaki50 zaki50 commented Jul 27, 2017

This PR implements #4165 and fixes #575.

TODO:
Required:

Optional/In prioritized order:

@zaki50 zaki50 added this to the 4.0 milestone Jul 27, 2017
@zaki50 zaki50 changed the title empty commit for feature/primitive_list PR Primitive List Support Jul 28, 2017
@zaki50 zaki50 changed the title Primitive List Support Support Primitive List feature Jul 31, 2017
@an-k an-k mentioned this pull request Aug 16, 2017
2 tasks
@zaki50 zaki50 force-pushed the feature/primitive_list branch from 9b957c3 to c8a8821 Compare September 5, 2017 02:49
* Nullability changes for Primitive List support

* more @nullable annotations

* fix annotation order

* Primitive List feature(Part3: Temporary fix of implementations and tests) (#5151)

* solve compilation errors related to Primitive List API changes

* revert test

* fix FB warnings

* fix failing tests

* Primitive List feature(Part4: Tests) (#5152)

* Add Primitive List fields to test classes

* removed tests for Primitive List for now

* removed tests for Primitive List for now

* Primitive List feature(Part5: Element type check in annotation processor) (#5168)

* @NotNull as alias for @required (#5161)

This PR adds support for org.jetbrains.annotations.NotNull as an alias for @required. This means that Realm now understands the Kotlin type-system in the Realm schema.

Previously we reported an error if you did @required RealmList<MyType> list = new RealmList<>();. It is a bit unclear why, since a RealmList is always non-null on managed objects. Since it made the interop with Kotlin kinda strange, I made a change so you can now do @required RealmList<MyType> list = new RealmLis<>() as well as val list : RealmList<MyType> = RealmList();

After this change it is no longer possible to do val person : Person either, you have to do val person : Person?. This reflects the constraints of Realm, but if people are able to maintain the variant themselves (hint: not possible when using sync), then they can use a custom non-null getter.

* implement elemenrt type check of RealmList

* fix error message

* remove extra line

* fix typo

* address review comments
@zaki50
Copy link
Copy Markdown
Contributor Author

zaki50 commented Sep 5, 2017

I've merged Part 1 to Part 5 into this PR.

zaki50 and others added 7 commits September 19, 2017 19:28
* generate getters and setters for primitive list

* empty commit for part9

* implement logic for primitive list in RealmList

* fix tests

* fix annotation processor unit tests

* throw an exception if query or aggregation feature is used for primitive list

* fix tests

* address findbugs issues

* added Javadoc comment and RealmList.toArray()

* fix bug

* implement Primitive List logic for copy() and insert()

* implement Primitive List logic for insert(Realm, Iterator,...)

* generate code for primitive list in update(), insertOrUpdate()

* minor refactoring

* implement primitive list supprt for copyFromRealm()

* added a test to get field meta data of primitive lists

* fix test

* fix #5233

* move ManagedListOperator classes from the inside of RealmList to outside

* Implement special handling for byte[] in RealmList

* avoid unnecessary looping

* use fqcn when makeing a string of value type.

* fix RealmList.toString()

* fix a bug

* fix bugs

* add instrumentation tests

* fix a bug that annotation processor always generates schema of primitive list as nullable

* fix implementation of RealmList.remove(Object)

* fix RealmListTests

* fix RealmListTests

* added tests for 'copyToRealm()' and 'copyFromRealm()'

* added tests for non-null primitive list

* fix test

* use OsObjectSchemaInfo.addPersistedValueListProperty()

* fix test

* introduce Row.getModelList() and Row.getValueList() to check field type more precisely

* update test case to expose an issue

* address review feedback

* add notice to Realm.*Json*()

* simplify Proxy's createDetachedCopy()

* stop to add backlink field into nullable field list

* add comments to ClassMetaData.hasRequiredAnnotation() and  ClassMetaData.isRequiredField()

* move Utils.getRealmListElementTypeMirror() to TypeMirrors class.

* fix exception message

* add class comment to TypeMirrors

* add TODO comment

* remove outdate comment

* fix todo comment

* fix failing test

* remove methods to return primitive array

* Using constans defined in Table class

* use assertArrayEquals() instead of assertTrue(Arrays.equals())

* add changelog entry about removed methods

* remove unused code

* update comment

* remove comment

* update exception message

* update thrown.expectMessage() to check exception message

* fix test case name

* add assertion for remove/removeAll

* update RealmList.toString()

* update exception message

* fix failing tests

* remove special handling to byte array in RealmList

* remove special type conversion via Number in toArray()

* remove unnecessary index checks

* refactor ManagedListOperator and its sub-classes

* use thrown.expectMessage()

* add Javadoc comments to ManagedListOperator and its subclasses

* address review comments
…tr_bug

Primitive List feature(Part14: bug fix (custom deleter for shared_ptr<char>))
…OsList

Primitive List feature(Part 13, Support listener on OsList)
Conflicts:
	realm/realm-library/src/androidTest/java/io/realm/RealmSchemaTests.java
	realm/realm-library/src/main/java/io/realm/RealmList.java
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed

zaki50 and others added 3 commits September 26, 2017 21:35
…n the elements are not RealmModel) (#5336)

* disable RealmList.createSnapshot()

* add changelog entry of primitive list

* fix CHANGELOG.md

* fix CHANGELOG.md

* update CHANGELOG.md
@cmelchior cmelchior merged commit d9e0ae4 into master Oct 1, 2017
@VenomVendor
Copy link
Copy Markdown

Great relief. Updating my code base to add Primitive support.

@cmelchior
Copy link
Copy Markdown
Contributor

@VenomVendor Keep in mind that queries are not supported in the initial release, but we will add them as soon as possible

@Zhuinden
Copy link
Copy Markdown
Contributor

Zhuinden commented Oct 1, 2017

@cmelchior and same for migration support for adding/removing RealmList of primitives to existing schema

@jonathansds
Copy link
Copy Markdown

How to use? It doesn't compile if I just use RealmList.

@Zhuinden
Copy link
Copy Markdown
Contributor

Zhuinden commented Oct 6, 2017

@jonathansds RealmList<String> and stuff like that.

@jonathansds
Copy link
Copy Markdown

It doesn't compile when I use RealmList < Long >

@jonathansds
Copy link
Copy Markdown

It says that "Long" doesn't extends RealmObject

@Zhuinden
Copy link
Copy Markdown
Contributor

Zhuinden commented Oct 6, 2017

@jonathansds are you using 4.0.0-RC1?

@jonathansds
Copy link
Copy Markdown

That was it! Sorry, missed that.

@cmelchior cmelchior deleted the feature/primitive_list branch November 20, 2017 12:14
@hardysim
Copy link
Copy Markdown

So this is very nice but it's limited to java.lang.String - can we get kotlin.String as well (and the other types)?

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RealmList<Integer / String / ...>

8 participants