public class LegacyObject {
private final UUID id; private final String foo; private final int bar;
public LegacyObject(UUID id, String foo, int bar) { this.id = id; this.foo = foo; this.bar = bar; }
@Override public int hashCode() { return Objects.hash(id); }
// Implementation of equals() using only the id field // Getters }
public class DeduplicateWrapper {
private final LegacyObject object;
public DeduplicateWrapper(LegacyObject object) { this.object = object; }
public LegacyObject getObject() { return object; }
@Override public int hashCode() { return Objects.hash(object.getFoo()); }
// Implementation of equals() using only the foo field of the wrapped object }
|