有什么方法可以使用Intellij Idea仅选择枚举名称吗?
...
public enum OrganizationActivityLogItemType implements IActivityLogItemType<OrganizationActivityLog>, DisplaysAs
{
@Deprecated GENE_VARIANT_PUBLIC( "Gene Variant/Mutation/Allele", null ),
VARIANTS_MUTATIONS( "Variants/Mutations/ Alleles/Loci/Probes", ALFactory.PUBLIC_PRIVATE ),
CATEGORIES( "Categories", null ),
PUBLIC_VISIBLITY_COVERED_WHEN_MEETS_NECESSITY_CRITERIA( "Covered - When Meets Medical Necessity Criteria",
ALFactory.PUBLIC_PRIVATE ),
PUBLIC_VISIBLITY_NOT_COVERED_INVESTIGATIONAL(
"Not Covered - Investigational",
ALFactory.PUBLIC_PRIVATE ),
PUBLIC_VISIBLITY_NOT_COVERED_NOT_MEDICALLY_NECESSARY(
"Not Covered - Not Medically Necessary",
ALFactory.PUBLIC_PRIVATE ),
...
最佳答案
Java中的枚举是扩展抽象类java.lang.Enum
的特殊类,因此继承了在那里定义的方法。您可以使用name()
方法获取枚举常量的名称。
name() method in Enum
OrganizationActivityLogItemType [] enumArray = OrganizationActivityLogItemType.values();
for(OrganizationActivityLogItemType enumObject: enumArray ){
System.out.println(enumObject.name());
}