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

Cannot use ImplicitCollectionMappingTransformer with DSL? #21

Open
victormikhailov77 opened this issue Oct 19, 2023 · 1 comment
Open

Comments

@victormikhailov77
Copy link

victormikhailov77 commented Oct 19, 2023

Hello!
I need to map machine-generated DTOs to object model, and I cannot annotate them , so im trying to convert previously annotation-based code to Kotlin DSL. While this is working fine for singluar fields, I cannot use this approach for collections - it shows compilation error.

example:

val mapper = mapper<FilterDto, Filter> {
     autoMap(AutoMappingStrategy.BY_NAME)
          FilterDto::targetTransformations mappedTo Filter::targetTransformations withTransformer ImplicitCollectionMappingTransformer::class. 
          FilterDto::valueTransformations mappedTo Filter::valueTransformations withTransformer ImplicitCollectionMappingTransformer::class
}    

which gives me compilation error "None of the following functions can be called with the arguments supplied:" on withTransformer usage.

Previous (annotation based) version was like this:

@MappedField(transformer = ImplicitCollectionMappingTransformer::class) val targetTransformations: List<TransformationDto>? = emptyList(),

What is correct usage of DSL-based version of ImplicitCollectionMappingTransformer ?

@victormikhailov77
Copy link
Author

neither I can define my own transformer for List to List mapping;

class TransformationTransformer : MappingTransformer<List<TransformationDto>?, List<Transformation>?> {
    
override fun transform(context: MappingTransformerContext<out List<TransformationDto>?>): List<Transformation>? {
   }
}

compilation error, when I add it to ShapeShiftBuilder transformers list:

        val shapeShift = ShapeShiftBuilder()
            .withMapping(mapper.mappingDefinition)
            .withTransformer(FilterTargetTransformer())
            .withTransformer(TransformationTransformer())
            ^^^^^^^^^ ERROR ^^^^^^^^
            .build()

Required:
MappingTransformerRegistration<out Any, out Any>
Found:
TransformationTransformer

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

1 participant