Hi there. I have found that `java.util.Optional` is written procedural style and has `ifnonnull` checks in each method. I propose to refactor `Optional` in accordance to OOP-style. This will eliminates all unnecessary `if`-statements, removes duplications and reduces bytecode size more then twice.
I have two solutions: 1. Completely dynamic that avoids single static `EMPTY` instance and unchecked casting of each `Optional.empty()` 2. Preserving original single static `EMPTY` per VM. Also there are couple methods that throws NPE due to calling methods on null-objects and requires to add `Objects.requireNonNull(...)`. OptionalInt, OptionalDouble, OptionalLong could be refactored same way even with remove of additional boolean variable `isPresent`. Since I'm new here any guidance will be helpful. Thank you in advance.