INNER CODE UNIT · Java
safe
SeaseLtd/rated-ranking-evaluator · rre-core/src/main/java/io/sease/rre/Func.java:54
public static <T> T[] safe(final T[] values) {
return values != null ? values : emptyList().toArray(values);
}
/**
* Makes sure a non-null array is returned.
* This is used in iterations, in order to avoid NPE.
*
* @param values the input array.
* @param <T> the array type.
* @return the same array, if it's not null, an empty array otherwise.
*/
public static <T> List<T> safe(final List<T> values) {
return values != null ? values : emptyList();
}
/**
* Converts the content of the given file to a JSON node.