Skip to content

Commit 9700917

Browse files
committed
Shaded classes from Guava to keep the API stable
1 parent 6e1f43f commit 9700917

File tree

8 files changed

+624
-62
lines changed

8 files changed

+624
-62
lines changed

project.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ targetCompatibility = JavaVersion.VERSION_1_6; // defaults to sourceCompatibilit
3131
dependencies {
3232
implementation(group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.9.9");
3333
implementation(group: "com.github.fge", name: "msg-simple", version: "1.1");
34-
implementation(group: "com.google.code.findbugs", name: "jsr305", version: "2.0.1");
35-
testImplementation(group: "org.testng", name: "testng", version: "6.8.7") {
34+
implementation(group: "com.google.code.findbugs", name: "jsr305", version: "3.0.2");
35+
testImplementation(group: "org.testng", name: "testng", version: "7.0.0-beta1") {
3636
exclude(group: "junit", module: "junit");
3737
exclude(group: "org.beanshell", module: "bsh");
3838
exclude(group: "org.yaml", module: "snakeyaml");

src/main/java/com/github/fge/jackson/JsonNumEquals.java

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
package com.github.fge.jackson;
2121

2222
import com.fasterxml.jackson.databind.JsonNode;
23+
import com.google.common.base.Equivalence;
2324

24-
import javax.annotation.Nullable;
2525
import java.util.HashSet;
2626
import java.util.Iterator;
2727
import java.util.Map;
@@ -41,50 +41,21 @@
4141
* kind of equality.</p>
4242
*/
4343
public final class JsonNumEquals
44+
extends Equivalence<JsonNode>
4445
{
45-
private static final JsonNumEquals INSTANCE
46+
private static final Equivalence<JsonNode> INSTANCE
4647
= new JsonNumEquals();
4748

4849
private JsonNumEquals()
4950
{
5051
}
5152

52-
public static JsonNumEquals getInstance()
53+
public static Equivalence<JsonNode> getInstance()
5354
{
5455
return INSTANCE;
5556
}
5657

57-
/**
58-
* Returns {@code true} if the given objects are considered equivalent.
59-
*
60-
* <p>The {@code equivalent} method implements an equivalence relation on object references:
61-
*
62-
* <ul>
63-
* <li>It is <i>reflexive</i>: for any reference {@code x}, including null, {@code
64-
* equivalent(x, x)} returns {@code true}.
65-
* <li>It is <i>symmetric</i>: for any references {@code x} and {@code y}, {@code
66-
* equivalent(x, y) == equivalent(y, x)}.
67-
* <li>It is <i>transitive</i>: for any references {@code x}, {@code y}, and {@code z}, if
68-
* {@code equivalent(x, y)} returns {@code true} and {@code equivalent(y, z)} returns {@code
69-
* true}, then {@code equivalent(x, z)} returns {@code true}.
70-
* <li>It is <i>consistent</i>: for any references {@code x} and {@code y}, multiple invocations
71-
* of {@code equivalent(x, y)} consistently return {@code true} or consistently return {@code
72-
* false} (provided that neither {@code x} nor {@code y} is modified).
73-
* </ul>
74-
* @param a x
75-
* @param b y
76-
* @return whether nodes are equal according to IETF RFCs
77-
*/
78-
public final boolean equivalent(@Nullable JsonNode a, @Nullable JsonNode b) {
79-
if (a == b) {
80-
return true;
81-
}
82-
if (a == null || b == null) {
83-
return false;
84-
}
85-
return doEquivalent(a, b);
86-
}
87-
58+
@Override
8859
protected boolean doEquivalent(final JsonNode a, final JsonNode b)
8960
{
9061
/*
@@ -122,31 +93,7 @@ protected boolean doEquivalent(final JsonNode a, final JsonNode b)
12293
return typeA == NodeType.ARRAY ? arrayEquals(a, b) : objectEquals(a, b);
12394
}
12495

125-
/**
126-
* Returns a hash code for {@code t}.
127-
*
128-
* <p>The {@code hash} has the following properties:
129-
* <ul>
130-
* <li>It is <i>consistent</i>: for any reference {@code x}, multiple invocations of
131-
* {@code hash(x}} consistently return the same value provided {@code x} remains unchanged
132-
* according to the definition of the equivalence. The hash need not remain consistent from
133-
* one execution of an application to another execution of the same application.
134-
* <li>It is <i>distributable across equivalence</i>: for any references {@code x} and {@code y},
135-
* if {@code equivalent(x, y)}, then {@code hash(x) == hash(y)}. It is <i>not</i> necessary
136-
* that the hash be distributable across <i>inequivalence</i>. If {@code equivalence(x, y)}
137-
* is false, {@code hash(x) == hash(y)} may still be true.
138-
* <li>{@code hash(null)} is {@code 0}.
139-
* </ul>
140-
* @param t node to hash
141-
* @return hash
142-
*/
143-
public final int hash(@Nullable JsonNode t) {
144-
if (t == null) {
145-
return 0;
146-
}
147-
return doHash(t);
148-
}
149-
96+
@Override
15097
protected int doHash(final JsonNode t)
15198
{
15299
/*

0 commit comments

Comments
 (0)