I agree, as with many things it depends on the use case. The way I see it, Optional parameter declares in no uncertain way that passed wrapped argument can be null and the method knows it. That does not mean I use it often, or at all really, I can think or two uses in couple of years. But some people seem to be religiously opposed to it.
Using a @Nullable or @NotNull annotation would do the same without the overhead of creating an object to avoid a null check. Not to mention the clutter in the code of wrapping your parameters.
2
u/Paulus_cz Apr 14 '23
I agree, as with many things it depends on the use case.
The way I see it, Optional parameter declares in no uncertain way that passed wrapped argument can be null and the method knows it. That does not mean I use it often, or at all really, I can think or two uses in couple of years. But some people seem to be religiously opposed to it.