@Mapper
public interface MyMapper<X extends Base_1, Y extends Base_2>{
public X mapBase_2ToBase_1(Y obj);
}
我想将泛型类型的对象映射Y
到另一个泛型类型的对象X
。使用mapstruct可以实现类似的事情吗?还是我必须为通用映射编写自定义映射器?当我编译上面的代码时,我得到了编译错误。
Caused by: java.lang.NullPointerException
at org.mapstruct.ap.util.SpecificCompilerWorkarounds.replaceTypeElementIfNecessary(SpecificCompilerWorkarounds.java:90)
at org.mapstruct.ap.util.Executables.getAllEnclosedExecutableElements(Executables.java:189)
at org.mapstruct.ap.model.common.Type.getAllExecutables(Type.java:395)
at org.mapstruct.ap.model.common.Type.getSetters(Type.java:464)
at org.mapstruct.ap.model.common.Type.getPropertyWriteAccessors(Type.java:353)
at org.mapstruct.ap.model.BeanMappingMethod$Builder.souceMethod(BeanMappingMethod.java:93)
at org.mapstruct.ap.processor.MapperCreationProcessor.getMappingMethods(MapperCreationProcessor.java:345)
at org.mapstruct.ap.processor.MapperCreationProcessor.getMapper(MapperCreationProcessor.java:143)
at org.mapstruct.ap.processor.MapperCreationProcessor.process(MapperCreationProcessor.java:114)
at org.mapstruct.ap.processor.MapperCreationProcessor.process(MapperCreationProcessor.java:73)
at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:193)
at org.mapstruct.ap.MappingProcessor.processMapperTypeElement(MappingProcessor.java:173)
at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:154)