smartstruct icon indicating copy to clipboard operation
smartstruct copied to clipboard

Add lifecycle methods (after & before)

Open DenisBogatirov opened this issue 2 years ago • 1 comments

It would be very helpful to have annotations for BeforeMapping & AfterMapping like the original mapstruct has.

Example usage:

class Source {}

class Target {
  Service _service;
  
  void setSevice(Service service) {
    _service = service;
  }
}

@Mapper()
abstract class SourceToTargetMapper {
  Service _service;

  SourceToTargetMapper(Service service) {
    _service = service;
  }

  Target fromSource(Source source);
  
  @AfterMapping()
  void afterMapping(Target target) {
    target.setService(_service);
  }
}

DenisBogatirov avatar Jan 24 '23 13:01 DenisBogatirov

Hi, like the idea a lot, should also be relatively easy to implement

smotastic avatar Feb 05 '23 16:02 smotastic