Skip to content

Commit

Permalink
Shaded classes from Guava to keep the API stable
Browse files Browse the repository at this point in the history
  • Loading branch information
soberich committed Nov 2, 2019
1 parent 30d13f4 commit 7e26865
Show file tree
Hide file tree
Showing 8 changed files with 624 additions and 62 deletions.
4 changes: 2 additions & 2 deletions project.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ targetCompatibility = JavaVersion.VERSION_1_7; // defaults to sourceCompatibilit
dependencies {
implementation(group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.9.9");
implementation(group: "com.github.fge", name: "msg-simple", version: "1.1");
implementation(group: "com.google.code.findbugs", name: "jsr305", version: "2.0.1");
testImplementation(group: "org.testng", name: "testng", version: "6.8.7") {
implementation(group: "com.google.code.findbugs", name: "jsr305", version: "3.0.2");
testImplementation(group: "org.testng", name: "testng", version: "7.0.0-beta1") {
exclude(group: "junit", module: "junit");
exclude(group: "org.beanshell", module: "bsh");
exclude(group: "org.yaml", module: "snakeyaml");
Expand Down
65 changes: 6 additions & 59 deletions src/main/java/com/github/fge/jackson/JsonNumEquals.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package com.github.fge.jackson;

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.base.Equivalence;

import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
Expand All @@ -41,50 +41,21 @@
* kind of equality.</p>
*/
public final class JsonNumEquals
extends Equivalence<JsonNode>
{
private static final JsonNumEquals INSTANCE
private static final Equivalence<JsonNode> INSTANCE
= new JsonNumEquals();

private JsonNumEquals()
{
}

public static JsonNumEquals getInstance()
public static Equivalence<JsonNode> getInstance()
{
return INSTANCE;
}

/**
* Returns {@code true} if the given objects are considered equivalent.
*
* <p>The {@code equivalent} method implements an equivalence relation on object references:
*
* <ul>
* <li>It is <i>reflexive</i>: for any reference {@code x}, including null, {@code
* equivalent(x, x)} returns {@code true}.
* <li>It is <i>symmetric</i>: for any references {@code x} and {@code y}, {@code
* equivalent(x, y) == equivalent(y, x)}.
* <li>It is <i>transitive</i>: for any references {@code x}, {@code y}, and {@code z}, if
* {@code equivalent(x, y)} returns {@code true} and {@code equivalent(y, z)} returns {@code
* true}, then {@code equivalent(x, z)} returns {@code true}.
* <li>It is <i>consistent</i>: for any references {@code x} and {@code y}, multiple invocations
* of {@code equivalent(x, y)} consistently return {@code true} or consistently return {@code
* false} (provided that neither {@code x} nor {@code y} is modified).
* </ul>
* @param a x
* @param b y
* @return whether nodes are equal according to IETF RFCs
*/
public final boolean equivalent(@Nullable JsonNode a, @Nullable JsonNode b) {
if (a == b) {
return true;
}
if (a == null || b == null) {
return false;
}
return doEquivalent(a, b);
}

@Override
protected boolean doEquivalent(final JsonNode a, final JsonNode b)
{
/*
Expand Down Expand Up @@ -122,31 +93,7 @@ protected boolean doEquivalent(final JsonNode a, final JsonNode b)
return typeA == NodeType.ARRAY ? arrayEquals(a, b) : objectEquals(a, b);
}

/**
* Returns a hash code for {@code t}.
*
* <p>The {@code hash} has the following properties:
* <ul>
* <li>It is <i>consistent</i>: for any reference {@code x}, multiple invocations of
* {@code hash(x}} consistently return the same value provided {@code x} remains unchanged
* according to the definition of the equivalence. The hash need not remain consistent from
* one execution of an application to another execution of the same application.
* <li>It is <i>distributable across equivalence</i>: for any references {@code x} and {@code y},
* if {@code equivalent(x, y)}, then {@code hash(x) == hash(y)}. It is <i>not</i> necessary
* that the hash be distributable across <i>inequivalence</i>. If {@code equivalence(x, y)}
* is false, {@code hash(x) == hash(y)} may still be true.
* <li>{@code hash(null)} is {@code 0}.
* </ul>
* @param t node to hash
* @return hash
*/
public final int hash(@Nullable JsonNode t) {
if (t == null) {
return 0;
}
return doHash(t);
}

@Override
protected int doHash(final JsonNode t)
{
/*
Expand Down
Loading

0 comments on commit 7e26865

Please sign in to comment.