Incorrect equals
, hashCode
and toString
in GenericData
#936
Labels
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
GenericData
is the base class for 'requst' and 'response' objects in Google Java API bindings. It inheritsequals
fromAbstractHashMap
, which is a mistake. Let's consider this expression (Directory API):Intuition says it should be
false
, but in fact istrue
, because in this example it happens that both left and right side has exactly the same keys and values in theAbstractHashMap
, which makes strange errors for example when somebody tries to put objects to ownHashMaps
(eg to make some simple caching).The reason of this problem is that
AbstractHashMap.equals
andAbstractHashMap.hashCode
dosn't takethis.getClass()
into account (just like all implementations ofMap
do), butGenericData
isn't just aMap
, it's just a regular object with generic access mechanism, and IMHO should have validequals
andhashCode
implemented.The same is as for
toString
: strings like{...}
don't tell me of which class this object is, eg is thisdirectory.users().list()
request ordirectory.groups().list()
request?The text was updated successfully, but these errors were encountered: