Partly because that’s what I’ve always done, partly because it works, and partly because its easier for me to interpret and read.
So why aren’t you still coding in scratch?
Optionals were added to make code safer without extra bulk or assumptions.
If you’re using Optionals well (ie not blindly calling get) they work too!
This is a personal preference, but "unsafeMethod().ifPresent(myThing → doStuff()) is more readable in “plain english” terms.
I still prefer having an object and checking it on my own. Optionals just muddy up the water for me because I can do myself what they intend to do.
I get it. Optionals are a way of idiot proofing and preventing things like people calling Bukkit.getPlayer() and using the result without a null check. It makes people certain of the state of an object.
I know why they’re implemented and I know the “benefits” behind them. I just stubbornly choose to do null checks on my own.
Fight me.
one of my favorite parts of scala
implicit def unwrapOptional[T](opt: Optional[T]): T = opt orElse null
implicit def wrapOptional[T](t: T): Optional[T] = Optional ofNullable t
and then you can ignore all optionals you weren’t intending to check
if you’ve never used scala, if an implicit function is visible which takes one type and returns another, then the first type can be used as the other; the compiler inserts the function call