[java] Fix if to ternary conversion for null else type