File tree Expand file tree Collapse file tree
main/java/com/jsoniter/any
test/java/com/jsoniter/any Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
44 <modelVersion >4.0.0</modelVersion >
55 <groupId >com.jsoniter</groupId >
6- <version >0.9.13 </version >
6+ <version >0.9.14-SNAPSHOT </version >
77 <artifactId >jsoniter</artifactId >
88 <name >json iterator</name >
99 <description >jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go</description >
Original file line number Diff line number Diff line change @@ -333,4 +333,22 @@ public static Any rewrap(Map<String, Any> val) {
333333 protected boolean isWildcard (Object key ) {
334334 return wildcardHashCode == key .hashCode () && wildcard .equals (key );
335335 }
336+
337+ @ Override
338+ public boolean equals (Object o ) {
339+ if (this == o ) return true ;
340+ if (o == null || getClass () != o .getClass ()) return false ;
341+
342+ Any any = (Any ) o ;
343+
344+ Object obj = this .object ();
345+ Object thatObj = any .object ();
346+ return obj != null ? obj .equals (thatObj ) : thatObj == null ;
347+ }
348+
349+ @ Override
350+ public int hashCode () {
351+ Object obj = this .object ();
352+ return obj != null ? obj .hashCode () : 0 ;
353+ }
336354}
Original file line number Diff line number Diff line change @@ -63,4 +63,11 @@ public void test_fill_partial_then_iterate() {
6363 assertEquals (3 , iter .next ().toInt ());
6464 assertFalse (iter .hasNext ());
6565 }
66+
67+ public void test_equals_and_hashcode () {
68+ Any obj1 = JsonIterator .deserialize ("[1,2,3]" );
69+ Any obj2 = JsonIterator .deserialize ("[1, 2, 3]" );
70+ assertEquals (obj1 , obj2 );
71+ assertEquals (obj1 .hashCode (), obj2 .hashCode ());
72+ }
6673}
You can’t perform that action at this time.
0 commit comments