关于 enum 的问题
public enum ITSIssueType {Terminology, Mistranslation, Omission, Untranslated, Addition, Duplication, Inconsistency, Grammar,
Legal, Register, LocaleSpecificContent("locale-specific-content"), LocaleViolation("locale-violation"),
Style, Characters, Misspelling, Typographical, Formatting, InconsistentEntities("inconsistent-entities"),
Numbers, Markup, PatternProblem("pattern-problem"), Whitespace, Internationalization, Length,
NonConformance("non-conformance"), Uncategorized, Other;
public static ITSIssueType getIssueType(String name) {
for (ITSIssueType issueType : values()) {
if (issueType.toString().equals(name)) {
return issueType;
}
}
throw new IllegalArgumentException("No IssueType found for name '" + name + "'. Valid values: " + Arrays.toString(values()));
}
private final String name;
ITSIssueType() {
this.name = name();
}
ITSIssueType(String name) {
this.name = name;
}
@Override
public String toString() {
return name.toLowerCase();
}
}
我想问的是我加粗那段,枚举类型不应该是定义静态常量的吗?是常量的话就应该都是大写字母才对啊,可是这里却是只有首字母大写,我不明白,求哪位高人知道的指点下!