Package com.sun.enterprise.universal
Class JavaLangUtils
java.lang.Object
com.sun.enterprise.universal.JavaLangUtils
Utility class for all trivial functions missing in Java.
- Author:
- David Matejcek
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TIf the value is null, calls the supplier to obtain the default value.static <V,T> T If the value is null, calls the supplier to obtain the default value.
-
Method Details
-
nonNull
If the value is null, calls the supplier to obtain the default value.- Type Parameters:
T- expected type- Parameters:
value- provided valuesupplierOfDefault- must not be null.- Returns:
- value OR value provided by the supplier. Note that it may be null too.
-
nonNull
public static <V,T> T nonNull(V value, Function<V, T> function, Supplier<? extends T> supplierOfDefault) If the value is null, calls the supplier to obtain the default value.If the value is not null, applies the function.
- Type Parameters:
V- input value typeT- expected type- Parameters:
value- provided value - can be nullfunction- function to apply to the value. Must not be null.supplierOfDefault- can be null, then supplies null.- Returns:
- result of a function OR value provided by the supplier. Note that the returned value may be null too.
-