Add type-safe property paths overloads (#2126)#2128
Add type-safe property paths overloads (#2126)#2128emilienbev wants to merge 4 commits intoAddFTSfrom
Conversation
2ab363b to
574f973
Compare
574f973 to
4096ed0
Compare
Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
mp911de
left a comment
There was a problem hiding this comment.
This is a great start. I suggest to consider using <T> someMethod(TypedPropertyPath<P, ?>... paths) instead of TypedPropertyPath<?, ?> to constrain the originating entity type to a single type T. The context is e.g. distinct(Person::getName, Person::getAge) where you would likely want to avoid property references to other entities such as distinct(Person::getName, Order::getId). distinct(Person::getName, TypedPropertyPath.of(Person::getOrder).then(Order::getId) would still work because T is in both cases Person as the origin entity.
| * @param distinctFields the property paths to use as distinct fields. | ||
| * @since 6.1 | ||
| */ | ||
| default Object distinct(TypedPropertyPath<?, ?>... distinctFields) { |
There was a problem hiding this comment.
Introducing <T> to distinct(TypedPropertyPath<T, ?>... distinctFields) allows to limit property paths originating in the same type. This e.g. prevents distinct(Person::getName, Order::getName) as both properties come from different entities.
| * | ||
| * @param fields the property paths to project. | ||
| * @since 6.1 | ||
| */ |
There was a problem hiding this comment.
Constraining to R could make sense.
Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
Fixes #2126