ossgang / ossgang-commons

Apache License 2.0
4 stars 0 forks source link

Mapbackeds: Consider introducing an equalsMethod that treats arrays with same values as equal. #70

Open kaifox opened 2 years ago

kaifox commented 2 years ago

Currently, the mapbacked objects use the equals method of the underlying map.

If consequently uing collections below, everything is fine for data objects. However, if fields are declared as arrays, then two arrays are treated as not equal, even if they contain the same values....

Most probably this should be changed, as for domain objects, which even can be serialized and deserialized, these different instances should be equal, or? However this would require a big if/else and some reflective acrobatic, because of all the primitives ... or is there a simpler solution? Or should it not be changed at all?

The problem is highlighted in https://github.com/ossgang/ossgang-commons/blob/master/src/test/java/org/ossgang/commons/mapbackeds/ArrayFieldEqualsTest.java