List of usage examples for com.fasterxml.jackson.databind JsonNode hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:org.jboss.aerogear.sync.jsonmergepatch.JsonMergePatchDiff.java
public static JsonMergePatchDiff fromJsonNode(final JsonNode jsonNode) { try {//from w ww .j a v a 2 s . c om return new JsonMergePatchDiff(JsonMergePatch.fromJson(jsonNode), jsonNode.hashCode()); } catch (final JsonPatchException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:org.eel.kitchen.jsonschema.ref.SchemaNode.java
public SchemaNode(final SchemaContainer container, final JsonNode node) { this.container = container; this.node = node; hashCode = 31 * container.hashCode() + node.hashCode(); }
From source file:com.github.fge.jackson.JsonNumEquals.java
@Override protected int doHash(final JsonNode t) { /*//ww w . java 2 s.c o m * If this is a numeric node, we want the same hashcode for the same * mathematical values. Go with double, its range is good enough for * 99+% of use cases. */ if (t.isNumber()) return Double.valueOf(t.doubleValue()).hashCode(); /* * If this is a primitive type (other than numbers, handled above), * delegate to JsonNode. */ if (!t.isContainerNode()) return t.hashCode(); /* * The following hash calculations work, yes, but they are poor at best. * And probably slow, too. * * TODO: try and figure out those hash classes from Guava */ int ret = 0; /* * If the container is empty, just return */ if (t.size() == 0) return ret; /* * Array */ if (t.isArray()) { for (final JsonNode element : t) ret = 31 * ret + doHash(element); return ret; } /* * Not an array? An object. */ final Iterator<Map.Entry<String, JsonNode>> iterator = t.fields(); Map.Entry<String, JsonNode> entry; while (iterator.hasNext()) { entry = iterator.next(); ret = 31 * ret + (entry.getKey().hashCode() ^ doHash(entry.getValue())); } return ret; }