Hi, For a long while, I couldn't think of what to reply with. I just don't feel the problem of grouping fields together deserves to distort the API that much. I guess part of the problem is Java doesn't support a syntax for field references (even though VarHandleDesc are already implemented.) It occurs to me that the hash and equals don't really need VarHandle references. They really just need getters and don't actually need fields.
There is no reason you couldn't do a hash and equality on generated "properties." Although you'd have to avoid boxing problems. interface Getter<R, T> { } interface ObjectGetter<R, T> { public T get(R record); } interface ValueGetter<R, T> extends Getter<R, T> { } interface IntGetter extends Getter<R, Integer> { public int get(R record); } private static final Set<Getter<Point, ?>> GETTERS = Set.of((s) -> sx, (s) -> s.y); private static final EqualsSupport<Point> EQUALS = EqualsSupport.of(GETTERS) private static final HashsSupport<Point> HASHER = HashSupport.of(GETTERS); private static final Stringer<Point> TOSTRING = Stringer.of(GETTERS); // etc.. I think it might be possible to get working without explicit indy static <R> EqualsSupport<R> makeEquals(Set<Getter<R, ?>> getters) { EqualsSupport<O> equals = (a, b) -> true; for (var getter : getters) { if (getter instanceof ObjectGetter) { var g = (ObjectGetter<R, ?>) getter; var oldEquals = equals; equals = (a, b) -> oldEquals.apply(a, b) && Object.equals(g.get(a), g.get(b))); } else if (getter instanceof IntGetter) { var g = (IntGetter<R>) getter; var oldEquals = equals; equals = (a, b) -> oldEquals.apply(a, b) && g.get(a) == g.get(b)); } else { // etc... } } return equals; } I'm just not sure this would properly inline everything. But this is starting to get into bikeshedding. Thank you, Steven -- You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group. To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsubscr...@googlegroups.com. To view this discussion on the web, visit https://groups.google.com/d/msgid/mechanical-sympathy/4cc49b86-cec6-49a5-a200-2836e026a835%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.