在注释处理器中获取枚举属性

时间:2018-10-03 12:37:08

标签: java enums annotation-processing

我想为每个JAVA枚举及其属性生成一个Javascript对象。

例如此枚举:

# First create a parameter grid to make predictions
grid <- expand.grid(
  rs_glm5scale = seq(min(df5$rs_glm5scale), max(df5$rs_glm5scale), length.out = 1000),
  scenario = c("A", "B")
)

# Then make predictions
pred <- predict(
  model,
  newdata = grid,
  type = "response"
)

cond <- grid$scenario == "A" # to select predictions corresponding to scenario A

# Plot the predictions for category "A"
plot(grid$rs_glm5scale[cond], pred[cond], col = "darkgrey",
     ylim = c(0, 1), type = "l", lwd = 2)

# Add a line for category "B"
lines(grid$rs_glm5scale[!cond], pred[!cond], col = "black", lwd = 2)

legend("bottomright", c("A", "B"), col = c("darkgrey", "lightgrey"), lwd = 2)

我想生成一个类似于的JS文件:

@AllArgsConstructor
public enum ETypeModel {
  TYPE_I("Type modèle 1", 10),
  TYPE_II("Type modèle 2", 20);

  @Getter private String label;
  @Getter private int priority;
}

因此,我创建了一个注释处理器,现在我能够列出枚举的值(TYPE_I和TYPE_II),但是我不知道如何获取每个值的属性(标签和优先级)。

我当前的处理器:

const ETypeModel = {
    TYPE_I : {label: 'Type modèle 1', priority: 10},
    TYPE_II: {label: 'Type modèle 2', priority: 20}
};

0 个答案:

没有答案