In our IntelliJ plugin, we have a long-term data structure in the form of a hashset. The hashset stores objects whose hashcode should be determined by contained project and/or module objects.
The problem is that I was not able to find values that can be used to create an immutable hashcode, i.e. values that won't change over the lifecycle of a project/module object. The best candidates I could find were the name and the base path, which both can change on runtime.
I also considered using the default hashCode of the objects. Even though the default implementation of both classes don't implement the hashCode method, the objects returned by the API seem to be singleton. But I could not find any reference to this fact in the documentation and didn't want to base the logic solely on a behavior observed during limited testing.
Are module and project objects guaranteed to be singleton across their lifecycle?
If not, can you recommend a way of obtaining immutable hash-codes for such objects? (I also considered re-adding the objects when values change, but had problems reacting to certain changes; e.g. I could not figure out how to synchronously react to project renamings.)