-
Couldn't load subscription status.
- Fork 179
Open
Description
Consider a class A that has a field b of type List<C>. The type C, in turn, has a large number of fields c1, c2, c3,..., but two C objects are considered "same" if their c1 fields are equal (perhaps C is a data object and c1 is its identifier field).
These rules can be implemented by a custom IdentityStrategy like this:
public class SingleFieldIdentityStrategy implements IdentityStrategy
{
//...
public boolean equals(final Object working, final Object base)
{
return ((C) working).c1 == ((C) base).c1;
}
//...
}However, the diff summary generated by PrintingVisitor for two A objects is often overly long:
Property at path '/b[C [ \ c1 = "id123" \ c2 = "foo" \ c3= "bar" \ c4 = D [ \ d1 = "baz" \ d2 = "quux" \ d3 = E [ \ e1 = "xxx" \ e2 = "yyy" \ ] \ ] \ ]]/c4/d3/e2' has changed from [ yyy ] to [ zzz ]
It is not necessary to print the entire toString representation of the C type (which may include lots of nested objects), if the C object can be matched with its counterpart by a single field.
syzsh
Metadata
Metadata
Assignees
Labels
No labels