EnumSet and EnumMap
FEBRUARY 14, 2017
If you write a lot of Java code, then you should read that book and follow its advice. The iterable.spliterator() method is critical when it comes to stream performance, but writing a custom Spliterator from scratch is a non-trivial task. Write a benchmark afterwards to confirm your assumptions. This is especially true for maps like EnumMap that create their Entry objects on demand. This article discusses java.util.EnumSet. and java.util.EnumMap.