class CollectionFunctions {

    @SuppressWarnings("unchecked")
    public static <T, R> R[] simpleMapArray(T[] array, Function<T, R> mappingFn, Class<R> clazz) {
        if (array == null || array.length == 0){
            return (R[]) Array.newInstance(clazz, 0);
        } else {
            R[] result = (R[]) Array.newInstance(clazz, array.length);
            for (int index = 0; index < array.length; index++){
                result[index] = mappingFn.apply(array[index]);
            }
            return result;
        }
    }

    private  CollectionFunctions();

}