package cz.senslog.connector.tools.util;

import java.util.function.BiFunction;

public class Arrays {

    public static boolean equals(Object[] a, Object[] b, BiFunction<Object, Object, Boolean> compareTo) {
        if (a==b) { return true; }
        if (a==null || b==null) { return false; }

        int length = a.length;
        if (b.length != length) { return false; }

        for (int i = 0; i < length; i++) {
            Object o1 = a[i];
            Object o2 = b[i];
            if (!(o1==null ? o2==null : compareTo.apply(o1, o2))) {
                return false;
            }
        }
        return true;
    }
}
