1 package net.trajano.twiff.internal.util; 2 3 /*** 4 * Extends {@link org.apache.commons.lang.ObjectUtils} with Java 5.0 constructs. 5 * 6 * @author Archimedes Trajano 7 */ 8 public class ObjectUtils extends org.apache.commons.lang.ObjectUtils { 9 /*** 10 * Scans through a list of values and returns the first non-<code>null</code> 11 * value. If all values are <code>null</code>, this method will return 12 * <code>null</code>. 13 * 14 * @param <T> 15 * value type. 16 * @param values 17 * a list of values 18 * @return first non-<code>null</code>l value. 19 */ 20 public static <T extends Object> T defaultIfNull(final T... values) { 21 for (T value : values) { 22 if (value != null) { 23 return value; 24 } 25 } 26 return null; 27 } 28 }