This chapter includes 24 problems meant to draw your attention to several rules for working with Optional. The problems and solutions presented in this section are based on the Java language architect Brian Goetz's definition:
"Optional is intended to provide a limited mechanism for library method return types where there needed to be a clear way to represent no result, and using null for such was overwhelmingly likely to cause errors."
But where there are rules, there are exceptions as well. Therefore, do not conclude that the rules (or practices) presented here should be followed (or avoided) at all costs. As always, it depends on the problem, and you have to evaluate the situation, weighing up the pros and cons.
You may also like to check the CDI plugin (https://github.com/Pscheidl/FortEE) for Java EE (Jakarta EE) developed by Pavel Pscheidl. This is...