Given a String I need to get an Optional, whereby if the String is null or empty the result would be Optional.empty. I can do it this way:
String ppo = \"\"; Opt
You can use map :
String ppo=""; Optional ostr = Optional.ofNullable(ppo) .map(s -> s.isEmpty()?null:s); System.out.println(ostr.isPresent()); // prints false