Orika对象映射

问题描述

我正在尝试使用orika将String映射到UUID,但出现以下错误

sourceType = java.lang.String destinationType = java.util.UUID 发生错误:没有注册任何将String转换为UUID的转换器,也没有任何可以从String生成UUID的ObjectFactory


public class SourceType {
    private String firstId;

  //setters getters
}

public class DestinationType {
    private UUID firstId;
  //setters getters
}

mapperFactory.classMap(SourceType.class,DestinationType.class)
                .byDefault()
                .customize(new MyCustomMapper())
                .register();

private final class MyCustomMapper extends CustomMapper<SourceType,DestinationType> {
        @Override
        public void mapAtoB(final SourceType sourceType,final DestinationType destinationType,final MappingContext context) {
             destinationType.setFirstId(UUID.fromString(sourceType.getFirstId()));
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)