What methods should go into a java.util.Objects class in JDK 7?
Paul Benedict
pbenedict at apache.org
Sun Nov 15 01:28:07 UTC 2009
I would like to propose adding this method:
/**
* Selects the object if not {@code null}; otherwise fallsback to the
* specified default object.
*
* @param object the object to test
* @param defaultObject the default object
* @return the object if not {@code null}; otherwise the default object
*/
public static Object defaultIfNull(Object object, Object defaultObject) {
return (object != null) ? object : defaultObject;
}
Paul
More information about the core-libs-dev
mailing list