Question

I have a Java POJO class that I use in my project for Jackson deserialization from JSON. This class has various members, but the important member to consider is of the type java.util.SortedMap. I want to add the equals() and hashCode() to this class in order for me to compare instances of these classes with each other. Therefore, I used Eclipse's source code generation tool to create these two methods. I get the following warning message from the IDE:

The field type 'java.util.SortedMap' does not redeclare equals() and hashCode() - the resulting code may not work correctly.

Note that my POJO object that I am trying to create equals() and hashCode() for does have members of different java.util interfaces, like List and Map, but there are no warning messages about lack of equals() or hashCode() for those two interfaces.

I guess that a part of the problem is that I am not sure why implementation of SortedMap Jackson will deserialize JSON into. There are many different implementations of the SortedMap interface available in my classpath and some do override equals() and hashCode(), but it is still impossible (?) to know whether one of these implementations will be choses by Jackson.

Is this warning message something that I need to worry about? Anyone know of any workarounds for this problem?

Aside: I have no desire to use Lombok in this project.


Update

Filed the following bug for Eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=422184

Was it helpful?

Solution

You don't get warnings about List and Map because those interfaces do declare equals() and hashCode() methods.

Since SortedMap extends the Map interface which does have the methods and which should still work for SortedMap I think everything should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top