小编And*_*sky的帖子

如何使用mapstruct将enum转换为POJO?

如何使用 mapstruct 将 enum 转换为 POJO 而无需自定义实现?

例如

enum Type {
  T1, T2;

  private String description;

  private Type(String description) {
      this.description = description;
  }

  public String getDescription() { return this.description; }
}
Run Code Online (Sandbox Code Playgroud)

POJO之类的

class TypeDto {
   private Type code;
   private String description;
}
Run Code Online (Sandbox Code Playgroud)

仅供参考,我使用 MapStruct 1.1.0.Final。

java enums mapstruct

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

enums ×1

java ×1

mapstruct ×1