[JAVA-2612] Improve POJO Codec - support sub-classes with the bson creator Created: 25/Sep/17 Updated: 29/Oct/23 Resolved: 04/Dec/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | POJO |
| Affects Version/s: | None |
| Fix Version/s: | 3.6.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Ross Lawley | Assignee: | Ross Lawley |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
PR: https://github.com/mongodb/mongo-java-driver/pull/417 |
| Comments |
| Comment by Githook User [ 04/Dec/17 ] |
|
Author: {'username': 'jflorencio', 'email': 'joe@deal.com', 'name': 'Joseph Florencio'}Message: PojoCodec improvents for sub-classes Pojo Codec fixes with sub-classes and bson creator This commit tries to fix a few issues: 1. It was not possible to overload a getter in a sub-class and make the ``` } class Bar extends Foo { @Override public Long getNumber() { /*...*/ } } This was due to bridge methods not getting picked up, so even though 2.a. It was not possible to use a more specific type in a getter, but a ``` // Mutable class public void setNames(List<String> names) { /*...*/ } // or immutable class (both didn't work) } The first issue was that strict type equality was enforced. This is a The second issue was that various collections were boxed to specific 3. It was not possible to use immutable collections like Guava's 4. @BsonCreator annotations were only searched for in the target class, I moved code around a bit for better locality and some re-usability. In I tried to add test cases for all of the above things - they all failed
|
| Comment by Ross Lawley [ 04/Dec/17 ] |
|
A massive thank you to Joseph Florencio for the excellent pull request. |
| Comment by Githook User [ 04/Dec/17 ] |
|
Author: {'username': 'jflorencio', 'email': 'joe@deal.com', 'name': 'Joseph Florencio'}Message: PojoCodec improvents for sub-classes Pojo Codec fixes with sub-classes and bson creator This commit tries to fix a few issues: 1. It was not possible to overload a getter in a sub-class and make the ``` } class Bar extends Foo { @Override public Long getNumber() { /*...*/ } } This was due to bridge methods not getting picked up, so even though 2.a. It was not possible to use a more specific type in a getter, but a ``` // Mutable class public void setNames(List<String> names) { /*...*/ } // or immutable class (both didn't work) } The first issue was that strict type equality was enforced. This is a The second issue was that various collections were boxed to specific 3. It was not possible to use immutable collections like Guava's 4. @BsonCreator annotations were only searched for in the target class, I moved code around a bit for better locality and some re-usability. In I tried to add test cases for all of the above things - they all failed
|