Pass Source instance to a qualifiedByName method #3521
Unanswered
jlorenzocima
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Not on my computer right now, but this should work. Would you mind trying? @Mapper(componentModel = "spring", uses = { BEvalService.class })
public interface ABMapper {
AMapped map(A a, @Context Double delta);
@Mapping(target = "dataX", source = "dataX", qualifiedByName = "evaluateData")
@Mapping(target = "dataY", source = "dataY", qualifiedByName = "evaluateData")
@Mapping(target = "valid", source = "b", qualifiedByName = "validate") // < just use b here
BMapped map(B b, @Context Double delta);
} @Service
public class BEvalService {
@Named("evaluateData")
public Integer evaluateData(String valorOrigen, @Context Double delta) {
...
}
@Named("validate")
public boolean validate(B b, @Context Double delta) {
...
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the following code which is a simplification of the real code (very simplified!).
This code works correctly, however in order to implement the 'validate' method of the 'BEvalService' class that is used by the 'qualifiedByName' I need to pass the complete instance of 'B' as a parameter to be able to return a complete validation (remember that it is a simplification and the real class 'B' is much more complex).
Can be done? Does anyone know how?
Model
Mapper
qualifiedByName methods
Some use example
Beta Was this translation helpful? Give feedback.
All reactions