java reflective equals - is this impl correct?
    @Override public boolean equals(Object other)
    {
        if (other == null) { return false; }
        if (!(this.getClass().equals(other.getClass()))) { return false; }

        QueryOptions that = (QueryOptions)other;

        List<Object> thisValues = map(asList(this.getClass().getDeclaredFields()), new field2value(this));
        List<Object> thatValues = map(asList(that.getClass().getDeclaredFields()), new field2value(that));

        List<Boolean> fieldEquality = map(zip(thisValues, thatValues), fn_equal);
        return reduce(fieldEquality, fn_and, true);
    }


    static public class field2value implements Fn<Object, Field>
    {
        Object instance;
        public field2value(Object instance) { this.instance = instance; }

        public Object apply(Field val) {
            try { return val.get(instance); }
            catch (IllegalAccessException e) { error(e.toString()); return null; }
        }
    }

    static public Fn<Boolean, Pair> fn_equal = new Fn<Boolean, Pair>() {
        public Boolean apply(Pair val) {
            return isEqual(val.first, val.second);
        }
    };



    public static <R, T> R reduce(
            final Collection<? extends T> target,
            Fn2<R, R, T> fn_accumulate,
            R initializer
    )
    {
        R accumulated = initializer;
        for (T item: Collections.unmodifiableCollection(target))
        {
            accumulated = fn_accumulate.apply(accumulated, item);
        }
        return accumulated;
    }


java reflective equals - is this impl correct?
===

    @Override public boolean equals(Object other)
    {
        if (other == null) { return false; }
        if (!(this.getClass().equals(other.getClass()))) { return false; }

        QueryOptions that = (QueryOptions)other;

        List<Object> thisValues = map(asList(this.getClass().getDeclaredFields()), new field2value(this));
        List<Object> thatValues = map(asList(that.getClass().getDeclaredFields()), new field2value(that));

        List<Boolean> fieldEquality = map(zip(thisValues, thatValues), fn_equal);
        return reduce(fieldEquality, fn_and, true);
    }


    static public class field2value implements Fn<Object, Field>
    {
        Object instance;
        public field2value(Object instance) { this.instance = instance; }

        public Object apply(Field val) {
            try { return val.get(instance); }
            catch (IllegalAccessException e) { error(e.toString()); return null; }
        }
    }

    static public Fn<Boolean, Pair> fn_equal = new Fn<Boolean, Pair>() {
        public Boolean apply(Pair val) {
            return isEqual(val.first, val.second);
        }
    };



    public static <R, T> R reduce(
            final Collection<? extends T> target,
            Fn2<R, R, T> fn_accumulate,
            R initializer
    )
    {
        R accumulated = initializer;
        for (T item: Collections.unmodifiableCollection(target))
        {
            accumulated = fn_accumulate.apply(accumulated, item);
        }
        return accumulated;
    }

