Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support mapping of classes without default constructor #8

Open
Idane opened this issue Aug 2, 2022 · 0 comments
Open

Support mapping of classes without default constructor #8

Idane opened this issue Aug 2, 2022 · 0 comments
Labels
core ShapeShift Core enhancement New feature or request

Comments

@Idane
Copy link
Member

Idane commented Aug 2, 2022

When mapping to a class reference, one approach is to throw an exception if not all mapped fields correlate to the fields in the constructor.

data class PersonRecord(
    @MappedField
    val firstName: String,
    @MappedField
    val lastName: String,
    @MappedField
    val age: Int,
    val tel: String
)

data class PersonRecord(
    val firstName: String,
    val lastName: String,
    val age: Int
)

This requires changing the logic of how we do mapping currently. Instead of mapping right before assignments, we need to prepare all mappings in advance and then attempt to correlate the mapFroms to the constructor argument names. If not all arguments match and no default constructor is available, throw an exception.

@Idane Idane added enhancement New feature or request core ShapeShift Core labels Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core ShapeShift Core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant