File tree 2 files changed +23
-2
lines changed
main/java/com/fasterxml/jackson/databind/node
test/java/com/fasterxml/jackson/databind/node
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .databind .node ;
2
2
3
3
import java .io .IOException ;
4
+ import java .util .Objects ;
4
5
5
6
import com .fasterxml .jackson .core .*;
6
7
import com .fasterxml .jackson .core .io .CharTypes ;
@@ -164,13 +165,16 @@ public boolean equals(Object o)
164
165
if (o == this ) return true ;
165
166
if (o == null ) return false ;
166
167
if (o instanceof TextNode ) {
167
- return ((TextNode ) o )._value .equals (_value );
168
+ TextNode otherNode = (TextNode ) o ;
169
+ return Objects .equals (otherNode ._value , _value );
168
170
}
169
171
return false ;
170
172
}
171
173
172
174
@ Override
173
- public int hashCode () { return _value .hashCode (); }
175
+ public int hashCode () {
176
+ return Objects .hashCode (_value );
177
+ }
174
178
175
179
@ Deprecated // since 2.10
176
180
protected static void appendQuoted (StringBuilder sb , String content )
Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .databind .node ;
2
2
3
+ import static org .junit .Assert .assertNotEquals ;
4
+
3
5
public class TextNodeTest extends NodeTestBase
4
6
{
5
7
public void testText ()
@@ -36,4 +38,19 @@ public void testText()
36
38
assertFalse (TextNode .valueOf ("false" ).asBoolean (true ));
37
39
assertFalse (TextNode .valueOf ("false" ).asBoolean (false ));
38
40
}
41
+
42
+ public void testEquals ()
43
+ {
44
+ assertEquals (new TextNode (null ), new TextNode (null ));
45
+ assertEquals (new TextNode ("abc" ), new TextNode ("abc" ));
46
+ assertNotEquals (new TextNode (null ), new TextNode ("def" ));
47
+ assertNotEquals (new TextNode ("abc" ), new TextNode ("def" ));
48
+ assertNotEquals (new TextNode ("abc" ), new TextNode (null ));
49
+ }
50
+
51
+ public void testHashCode ()
52
+ {
53
+ assertEquals (0 , new TextNode (null ).hashCode ());
54
+ assertEquals ("abc" .hashCode (), new TextNode ("abc" ).hashCode ());
55
+ }
39
56
}
You can’t perform that action at this time.
0 commit comments