org.codehaus.jackson.JsonNode.equals()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(189)

本文整理了Java中org.codehaus.jackson.JsonNode.equals()方法的一些代码示例,展示了JsonNode.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.equals()方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:equals

JsonNode.equals介绍

[英]Equality for node objects is defined as full (deep) value equality. This means that it is possible to compare complete JSON trees for equality by comparing equality of root nodes.

Note: marked as abstract to ensure all implementation classes define it properly and not rely on definition from java.lang.Object.
[中]节点对象的相等定义为完全(深度)值相等。这意味着可以通过比较根节点的相等性来比较完整的JSON树的相等性。
注意:标记为抽象以确保所有实现类都正确定义它,而不依赖于java的定义。lang.Object。

代码示例

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

/**
   * Note: this method gets called iff <code>otherChildren</code>
   * is non-empty
   */
  private boolean _sameChildren(ArrayList<JsonNode> otherChildren)
  {
    int len = otherChildren.size();
    if (this.size() != len) { // important: call size() to handle case of null list...
      return false;
    }
    for (int i = 0; i < len; ++i) {
      if (!_children.get(i).equals(otherChildren.get(i))) {
        return false;
      }
    }
    return true;
  }
}

代码示例来源:origin: org.apache.avro/avro

/**
 * Adds a property with the given name <tt>name</tt> and
 * value <tt>value</tt>. Neither <tt>name</tt> nor <tt>value</tt> can be
 * <tt>null</tt>. It is illegal to add a property if another with
 * the same name but different value already exists in this schema.
 *
 * @param name The name of the property to add
 * @param value The value for the property to add
 * @deprecated use {@link #addProp(String, Object)}
 */
@Deprecated
public synchronized void addProp(String name, JsonNode value) {
 if (reserved.contains(name))
  throw new AvroRuntimeException("Can't set reserved property: " + name);
 if (value == null)
  throw new AvroRuntimeException("Can't set a property to null: " + name);
 JsonNode old = props.get(name);
 if (old == null)
  props.put(name, value);
 else if (!old.equals(value))
  throw new AvroRuntimeException("Can't overwrite property: " + name);
}

代码示例来源:origin: org.apache.avro/avro

private boolean defaultValueEquals(JsonNode thatDefaultValue) {
 if (defaultValue == null)
  return thatDefaultValue == null;
 if (Double.isNaN(defaultValue.getDoubleValue()))
  return Double.isNaN(thatDefaultValue.getDoubleValue());
 return defaultValue.equals(thatDefaultValue);
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public boolean equals(Object o)
{
  if (o == this) return true;
  if (o == null) return false;
  if (o.getClass() != getClass()) {
    return false;
  }
  ObjectNode other = (ObjectNode) o;
  if (other.size() != size()) {
    return false;
  }
  if (_children != null) {
    for (Map.Entry<String, JsonNode> en : _children.entrySet()) {
      String key = en.getKey();
      JsonNode value = en.getValue();
      JsonNode otherValue = other.get(key);
      if (otherValue == null || !otherValue.equals(value)) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: voldemort/voldemort

+ ". The new default is: "
                   + newField.defaultValue()));
} else if(!newField.defaultValue().equals(oldField.defaultValue())) {
  messages.add(new Message(Level.INFO,
               "Changed the default value for existing field "

代码示例来源:origin: camunda/camunda-bpm-platform

/**
   * Note: this method gets called iff <code>otherChildren</code>
   * is non-empty
   */
  private boolean _sameChildren(ArrayList<JsonNode> otherChildren)
  {
    int len = otherChildren.size();
    if (this.size() != len) { // important: call size() to handle case of null list...
      return false;
    }
    for (int i = 0; i < len; ++i) {
      if (!_children.get(i).equals(otherChildren.get(i))) {
        return false;
      }
    }
    return true;
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public boolean equals(Object o)
{
  if (o == this) return true;
  if (o == null) return false;
  if (o.getClass() != getClass()) {
    return false;
  }
  ObjectNode other = (ObjectNode) o;
  if (other.size() != size()) {
    return false;
  }
  if (_children != null) {
    for (Map.Entry<String, JsonNode> en : _children.entrySet()) {
      String key = en.getKey();
      JsonNode value = en.getValue();
      JsonNode otherValue = other.get(key);
      if (otherValue == null || !otherValue.equals(value)) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public boolean equals(final Object o)
{
  return o instanceof ReadOnlyJsonNode && delegate.equals(((ReadOnlyJsonNode)o).delegate);
}

代码示例来源:origin: org.mule.modules/mule-module-json

@Override
public boolean equals(Object obj)
{
  return node.equals(obj);
}

代码示例来源:origin: com.github.foodev/jsondiff

@Override
public boolean equals(Object obj) {
  return wrapped.equals(obj);
}

代码示例来源:origin: algesten/jsondiff

@Override
public boolean equals(Object obj) {
  return wrapped.equals(obj);
}

代码示例来源:origin: io.sphere/sphere-java-client

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  CustomObject that = (CustomObject) o;
  if (!container.equals(that.container)) return false;
  if (!key.equals(that.key)) return false;
  if (value != null ? !value.equals(that.value) : that.value != null) return false;
  return true;
}

代码示例来源:origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Override
public boolean equals(Object obj) {
  if (this == obj)
    return true;
  if (obj == null)
    return false;
  if (getClass() != obj.getClass())
    return false;
  JsonRepresentation other = (JsonRepresentation) obj;
  if (jsonNode == null) {
    if (other.jsonNode != null)
      return false;
  } else if (!jsonNode.equals(other.jsonNode))
    return false;
  return true;
}

代码示例来源:origin: org.apache.hadoop/avro

public boolean equals(Object other) {
 if (other == this) return true;
 if (!(other instanceof Field)) return false;
 Field that = (Field) other;
 return (position == that.position) &&
  (schema.equals(that.schema)) &&
  (defaultValue == null
   ? that.defaultValue == null
   : (defaultValue.equals(that.defaultValue)));
}
public int hashCode() { return schema.hashCode(); }

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl

/**
   * Note: this method gets called iff <code>otherChildren</code>
   * is non-empty
   */
  private boolean _sameChildren(ArrayList<JsonNode> otherChildren)
  {
    int len = otherChildren.size();
    if (this.size() != len) { // important: call size() to handle case of null list...
      return false;
    }
    for (int i = 0; i < len; ++i) {
      if (!_children.get(i).equals(otherChildren.get(i))) {
        return false;
      }
    }
    return true;
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.avro

private boolean defaultValueEquals(JsonNode thatDefaultValue) {
 if (defaultValue == null)
  return thatDefaultValue == null;
 if (Double.isNaN(defaultValue.getDoubleValue()))
  return Double.isNaN(thatDefaultValue.getDoubleValue());
 return defaultValue.equals(thatDefaultValue);
}

代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson

/**
   * Note: this method gets called iff <code>otherChildren</code>
   * is non-empty
   */
  private boolean _sameChildren(ArrayList<JsonNode> otherChildren)
  {
    int len = otherChildren.size();
    if (this.size() != len) { // important: call size() to handle case of null list...
      return false;
    }
    for (int i = 0; i < len; ++i) {
      if (!_children.get(i).equals(otherChildren.get(i))) {
        return false;
      }
    }
    return true;
  }
}

代码示例来源:origin: nz.ac.auckland.morc/morc

public boolean validate(String value) {
  try {
    if (value == null || !validJson()) return false;
    String expectedInput = getValue();
    logger.debug("Expected JSON Input: {},\nActual JSON Input: {}", expectedInput,
        value);
    if (value.isEmpty() || expectedInput.isEmpty()) return value.isEmpty() && expectedInput.isEmpty();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode expectedJson = mapper.readTree(expectedInput);
    JsonNode inputJson = mapper.readTree(value);
    boolean equal = expectedJson.equals(inputJson);
    if (!equal) logger.warn("Differences exist between the expected JSON value and the encountered value");
    return equal;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.motechproject/motech-testing-utils

@Override
public boolean matches(Object argument) {
  try {
    ObjectMapper objectMapper = new ObjectMapper();
    String actual = (String) argument;
    JsonNode expectedTree = objectMapper.readTree(expected);
    JsonNode actualTree = objectMapper.readTree(actual);
    return expectedTree.equals(actualTree);
  } catch (IOException e) {
    throw new MotechException("Json parsing failure", e);
  }
}

代码示例来源:origin: org.apache.cassandra.deps/avro

public boolean equals(Object other) {
 if (other == this) return true;
 if (!(other instanceof Field)) return false;
 Field that = (Field) other;
 return (name.equals(that.name)) &&
  (schema.equals(that.schema)) &&
  (defaultValue == null
   ? that.defaultValue == null
   : (defaultValue.equals(that.defaultValue))) &&
  (order.equals(that.order)) &&
  props.equals(that.props);
}
public int hashCode() { return name.hashCode() + schema.hashCode(); }

相关文章