mapstruct icon indicating copy to clipboard operation
mapstruct copied to clipboard

In this case, how do I convert in batches?

Open wjc133 opened this issue 9 years ago • 3 comments

bean

from:

public class ActivityCommand{
    private String id;
    private List<RuleCommand> validationRules;
}

public class RuleCommand{
    private String boundary;
    private String operator;
}

to:

public class RuleMeta{
    private String actId;
    private String boundary;
    private String operator;
}

for mapping this in batches, I write mapper like this:

@Mapper
public interface RuleMapping {
    RuleMeta getActivityRule(String actId, RuleCommand command);

    List<RuleMeta> getActivityRules(String actId, List<RuleCommand> command);
}

The single conversion worked, but batch not. How can I convert in this case?

wjc133 avatar Dec 20 '16 02:12 wjc133

@wjc133 this is not supported. But you can always write a handwritten method which will be called by MapStruct. You can do that by using a used mapper @Mapper(uses = ) or annotate a class with @Mapper, handle it in the same class and let MapStruct generate the abstract methods.

sjaakd avatar Dec 24 '16 10:12 sjaakd

Let me know if the answer is useful to you. I'll continue to close the issue in a short while.

sjaakd avatar Dec 24 '16 10:12 sjaakd

OK. Thx.

wjc133 avatar Dec 29 '16 09:12 wjc133