Skip to content

Map multiple fields to a single one #23

Description

@laurentthiebaudezm

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions