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

Map multiple fields to a single one #23

Open
laurentthiebaudezm opened this issue Mar 11, 2024 · 2 comments
Open

Map multiple fields to a single one #23

laurentthiebaudezm opened this issue Mar 11, 2024 · 2 comments

Comments

@laurentthiebaudezm
Copy link

Hi,

I have a structure like:

class Source {
  val field1: ...
  val field2: ...
 val otherField: ...
}

class Destination {
  val singleField: TargetField
  val otherField: ...
}

I'd like to create a mapping from (field1 + field2) to singleField (keeping btw otherField).

I can easily create a Transformer to handle this:

class MyTransformer : MappingTransformer<Source, TargetField> {

but I cannot declare the mapping using this transformer, then:

.withMapping<Source, Destination> {
    Source::Source mappedTo Destination::otherField
       ???  mappedTo Destination::singleField withTransformer MyTransformer::class
    }

This is probably not the right way to achieve my goal. How could do?

(I guess I could also use a Decorator but then my singleField should be declared as a var which is not acceptable in my case)

@fjr619
Copy link

fjr619 commented Jul 8, 2024

any update for this issue?

@Idane
Copy link
Member

Idane commented Jul 8, 2024

Hi @fjr619, due to lack of time we're currently not actively developing ShapeShift except for features we actively need in our projects. I think adding some sort of separate annotation/mechanism for a composite mapping is a welcome edition. If you'd like, you can pick it up yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants