LongNode(3) != IntNode(3)
See original GitHub issueThe equals
method for IntNode
is implemented so that only IntNode
s can be equal to other IntNode
s, regardless of numeric value. This is obvious with just a glance at the source code.
I can do a PR to fix this, but just want to confirm that this isn’t so by design first.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
AssertJ: how can I make JsonNode comparison handle ...
The 3 in the actual node is a LongNode (which I understand since the original map contains a 3L ); The 3 in...
Read more >com.fasterxml.jackson.databind.node.LongNode Java Examples
This page shows Java code examples of com.fasterxml.jackson.databind.node.LongNode.
Read more >LongNode (jackson-databind 2.6.0 API) - FasterXML
Numeric node that contains simple 64-bit integer values. Nested Class Summary. Nested classes/interfaces inherited from interface com.fasterxml.jackson.
Read more >NumericNode (jackson-databind 2.12.4 API) - Javadoc.io
Returns integer value for this node (as BigDecimal ), if and only if this node is numeric ( JsonNode.isNumber() returns true). abstract boolean ......
Read more >jackson-mapper-asl-1.6.3.jar
Name, jackson-mapper-asl-1.6.3.jar ; Class Version, Java 5 ; Locations. /tmp/jboss-as-7.1.0.Alpha2-SNAPSHOT/modules/org/codehaus/jackson/jackson-mapper-asl/main/ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I appreciate your reaching out first: makes sense.
This is by design, wrt default behavior. Users are encouraged to use
method with suitable
Comparator
implementation for customizing equality logic to their liking.The reason here is simply that attempting to support various kinds of coercion (
DoubleNode
,FloatNode
too, presumably;BigIntegerNode
,BigDecimalNode
) leads to unmaintanable system. So although I agree in that it is not unreasonable to expect equality here, I am not interested in following this trail down the likely rat hole.@grimsa Thank you for sharing this!
I wonder if there was some benefit to adding a configurable (Builder based) JsonNodeComparator on Jackson 2.11 or later? (possibly 3.0, to allow Java 8 method pointers)