[java] How to get the first non-null value in Java?