我有一个枚举:
public enum NotificationType {
OPEN("open"),
CLOSED("closed");
public String value;
NotificationType(String value) {
this.value = value;
}
}
Run Code Online (Sandbox Code Playgroud)
我想将自定义字符串openorclosed而不是OPENorCLOSED传递给实体。目前,我已将其映射到实体中,如下所示:
@Enumerated(EnumType.STRING)
private NotificationType notificationType;
Run Code Online (Sandbox Code Playgroud)
哪个是存储/获取枚举值的最佳方式?