java - 在枚举内部调用另一个枚举的方法

标签 java enums

我有一个 Java 枚举类,其定义如下:

public enum FTSF implements ME<FTSF>, SF {

  ID(DSF.ID.getCode(), "T Id", DSF.ID.getColumnName()),
  CURRENT_TS(DSF.CURRENT_TS.getCode(),
             DSF.CURRENT_TS.getDescription(),
             DSF.CURRENT_TS.getColumnName()),;

DSF​​ 枚举类定义如下:

public enum DSF implements ME<DSF>, SF {

  ID("Id", "Id", "externalId"),
  CURRENT_TS("CurrentTs", "Current Timestamp", "currentTs"),;

  // There are getCode(), getDescription() and getColumnName() methods defined in this class and so on ....

;

我对 FTSF 类中使用的 CURRENT_TS 声明类型有点困惑。因此,基本上,正如 FTSF 类中提到的,CURRENT_TS 枚举声明包含 DSF.CURRENT_TS.getCode() 等。所以,如果我正确理解,FTSF 类(对于 CURRENT_TS)正在从 DSF 类中提到的以下声明中获取第一个值(Current_Ts) ?

CURRENT_TS("CurrentTs", "当前时间戳", "currentTs"),;

最佳答案

如果DFS枚举的方法getCode返回枚举构造函数的第一个参数,那么您的确认是正确的:

So, if I understood, correctly, the FTSF class(for CURRENT_TS) is taking the first value(Current_Ts) from the following declaration which is mentioned in DSF class?

关于java - 在枚举内部调用另一个枚举的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34734051/

相关文章:

java - 使用多个 XML 处理器的最佳实践?

swift - 具有 Void 关联类型的通用 Swift 4 枚举

c# - 从枚举中获取值

python - 在 Django 模型中指定 mySQL ENUM

java - Android - 恢复对话框?

java - 在JEE(JBoss)环境中的neo4j:

java - 线性搜索数组和字符串

python - 如何获取 python protobuf 消息的枚举字段的值名称

c++ - 错误 : expected ')' before 'tokenType' in method declaration

java - Maven Tomcat7 运行依赖 war