java 8 replace if else with optional