Skip to content

Commit e7d6eef

Browse files
committed
shaded classes from Guava to keep the API stable
1 parent 07b028a commit e7d6eef

File tree

10 files changed

+688
-61
lines changed

10 files changed

+688
-61
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ artifacts {
7777

7878
wrapper {
7979
gradleVersion = "5.0";
80-
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
80+
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
8181
}
8282

8383
task pom {

pom.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>java-json-tools</groupId>
6+
<artifactId>jackson-coreutils</artifactId>
7+
<version>1.10-SNAPSHOT</version>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<groupId>org.apache.maven.plugins</groupId>
12+
<artifactId>maven-compiler-plugin</artifactId>
13+
<version>3.8.0</version>
14+
<configuration>
15+
<source>1.6</source>
16+
<target>1.6</target>
17+
</configuration>
18+
</plugin>
19+
</plugins>
20+
</build>
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.fasterxml.jackson.core</groupId>
24+
<artifactId>jackson-databind</artifactId>
25+
<version>2.9.7</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.github.fge</groupId>
29+
<artifactId>msg-simple</artifactId>
30+
<version>1.1</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.google.code.findbugs</groupId>
34+
<artifactId>jsr305</artifactId>
35+
<version>3.0.2</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.testng</groupId>
39+
<artifactId>testng</artifactId>
40+
<version>7.0.0-beta1</version>
41+
<scope>test</scope>
42+
<exclusions>
43+
<exclusion>
44+
<artifactId>junit</artifactId>
45+
<groupId>junit</groupId>
46+
</exclusion>
47+
<exclusion>
48+
<artifactId>snakeyaml</artifactId>
49+
<groupId>org.yaml</groupId>
50+
</exclusion>
51+
<exclusion>
52+
<artifactId>bsh</artifactId>
53+
<groupId>org.beanshell</groupId>
54+
</exclusion>
55+
</exclusions>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.mockito</groupId>
59+
<artifactId>mockito-core</artifactId>
60+
<version>2.23.4</version>
61+
<scope>test</scope>
62+
</dependency>
63+
</dependencies>
64+
</project>

project.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ targetCompatibility = JavaVersion.VERSION_1_6; // defaults to sourceCompatibilit
3131
dependencies {
3232
implementation(group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.9.7");
3333
implementation(group: "com.github.fge", name: "msg-simple", version: "1.1");
34+
// compile(group: "com.google.guava", name: "guava", version: "16.0.1");
3435
implementation(group: "com.google.code.findbugs", name: "jsr305", version: "3.0.2");
3536
testImplementation(group: "org.testng", name: "testng", version: "7.0.0-beta1") {
3637
exclude(group: "junit", module: "junit");

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)