smallrye / jandex

Java Annotation Indexer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add `ClassInfo.enumConstants()`

Ladicek opened this issue · comments

Currently, it is a bit inconvenient to obtain the list of enum constants, one basically has to resort to code like this:

List<FieldInfo> enumConstants = enumClass.unsortedFields()
        .stream()
        .filter(FieldInfo::isEnumConstant)
        .collect(Collectors.toList());

Also one has to remember to use unsortedFields(), because fields() return fields in lexicographical order, which is useless when one needs to figure out the ordinal of each enum constant.

We should add an enumConstants() method that would basically do the same thing as above (except a bit more efficiently).

This can be done in a micro release.