Skip to content

Introduce KIterablePropertyPath #3241

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from

Conversation

mipo256
Copy link
Contributor

@mipo256 mipo256 commented Feb 9, 2025

Fixes #3010. Fixes the issue in the type safe way, so that this now works :

class User(val addresses: List<Address>)
class Address(val street: String)

User::addresses / Author::street contains "Austin" 

Where toDotPath() renders to addresses.street. In order to solve this ticket in the type safe way, without easing the generic boundary from KProperty1<T, U> to KProperty1<Any, U>, a new KIterablePropertyPath needs to be introduced. The solution with KProperty1<Any, U> allows for non type safe usages of the API, which is not generally a good idea to begin with.

Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 9, 2025
@mp911de mp911de self-assigned this Feb 10, 2025
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 10, 2025
@mp911de mp911de added this to the 3.5 M1 (2025.0.0) milestone Feb 10, 2025
@mp911de mp911de changed the title DATACMNS-3010 Introduced KIterablePropertyPath Introduce KIterablePropertyPath` Feb 10, 2025
@mp911de mp911de changed the title Introduce KIterablePropertyPath` Introduce KIterablePropertyPath Feb 10, 2025

class User(val addresses: List<Address>)

class Address(val street: String)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Space indents

*/
internal fun asString(property: KProperty<*>): String {
return when (property) {
is KPropertyPath<*, *> ->
"${asString(property.parent)}.${property.child.name}"
is KIterablePropertyPath<*, *> ->
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Space indents

mp911de pushed a commit that referenced this pull request Feb 10, 2025
…s using collections.

See #3010
Original pull request: #3241

Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
mp911de added a commit that referenced this pull request Feb 10, 2025
Add since tags. Reformat code. Switch to Collection-typed properties as Iterable is often used in domain models without being an actual mapped collection.

See #3010
Original pull request: #3241
@mp911de
Copy link
Member

mp911de commented Feb 10, 2025

Thank you for your contribution. That's merged and polished now.

@mp911de mp911de closed this Feb 10, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KPropertyPath doesn't support Iterables
3 participants