Thanks for your comment. In your example with the translation:
- Optional.empty(), is what I would return.
- Also I think an IllegalArgumentException could be appropriate but returning null is not an option for me.
-even if Map.get() returns null it doesn't mean is a good thing to do in other places. I don't criticise the implementation of Map but I don't like returning nulls.
You commented that null has a performance "pro", even if it does I don't think it outweights the benefit of avoiding null in first place.
One last thing I thought is I don't understand why would Optional would complicate the code? Before Optional I think a coding practice was to overload methods and constructors so that you could call the function with what you had available but this was not a guarantee that the right method would be called, but now you can use Optional on your parameters and on your return types so that you don't have to use null.
Sorry I am not convinced that there are any benefits on returning null regardless the contract