public static <T, R> boolean equalProperties(final T val1,
                                                 final T val2,
                                                 final Function<T, R> getter) {
        if (val1 == null && val2 == null) {
            return true;
        } else if (val1 != null && val2 == null) {
            return false;
        } else if (val1 == null) {
            return false;
        } else {
            Objects.requireNonNull(getter);
            final R result1 = getter.apply(val1);
            final R result2 = getter.apply(val2);
            return Objects.equals(result1, result2);
        }
    }
Test if the properties (accessed using the same getter for both) of two
objects of the same class are equal in a null safe way.

@return True if val1 and val2 are both null or if the results of applying {@code getter}
to va1 and val2 are equal.
stroom-util-shared/src/main/java/stroom/util/shared/NullSafe.java