在 Guava 的 joiner 中使用 enumset

Using enumset in Guava's joiner

我正在努力将枚举集转换为枚举集中的一串值。目前,我正在使用 Joiner.on(',').join(enumset)) 创建一串值。但是,我想知道 enumset 提供的排序保证是什么?

谢谢!!

是的,有保证。请参阅 EnumSet.

的 Javadoc

The iterator returned by the iterator method traverses the elements in their natural order (the order in which the enum constants are declared). The returned iterator is weakly consistent: it will never throw ConcurrentModificationException and it may or may not show the effects of any modifications to the set that occur while the iteration is in progress.