当前位置: 首页>>代码示例>>Java>>正文


Java JsonNode.equals方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.equals方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.equals方法的具体用法?Java JsonNode.equals怎么用?Java JsonNode.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


在下文中一共展示了JsonNode.equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pathAny

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * PathAny matcher that checks if any element of the final
 * result matches the expected result.
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if any single element of the final result matches
 *         the expected result, False if none matched
 */
public static boolean pathAny(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (element.equals(expectedResult)) {
            return true;
        }
    }
    return false;

}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:27,代码来源:AcceptorPathMatcher.java

示例2: pathAny

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * PathAny matcher that checks if any element of the final
 * result matches the expected result
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if any single element of the final result matches
 * the expected result, False if none matched
 */
public static boolean pathAny(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (element.equals(expectedResult)) {
            return true;
        }
    }
    return false;

}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:27,代码来源:AcceptorPathMatcher.java

示例3: compareJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
public static void compareJson(String expected, String actual) throws IOException {
  if(ElasticsearchCluster.USE_EXTERNAL_ES5){
    // ignore json comparison for now
    return;
  }

  ObjectMapper m = new ObjectMapper();
  JsonNode expectedRootNode = m.readTree(expected);
  JsonNode actualRootNode = m.readTree(actual);
  if (!expectedRootNode.equals(actualRootNode)) {
    ObjectWriter writer = m.writerWithDefaultPrettyPrinter();
    String message = String.format("Comparison between JSON values failed.\nExpected:\n%s\nActual:\n%s", expected, actual);
    // assertEquals gives a better diff
    assertEquals(message, writer.writeValueAsString(expectedRootNode), writer.writeValueAsString(actualRootNode));
    throw new RuntimeException(message);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:ElasticBaseTestQuery.java

示例4: compare

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public int compare(JsonNode o1, JsonNode o2) {
    if (o1.equals(o2)) {
        return 0;
    }
    if ((o1 instanceof NumericNode) && (o2 instanceof NumericNode)) {
        double d1 = ((NumericNode) o1).asDouble();
        double d2 = ((NumericNode) o2).asDouble();
        return Double.compare(d1, d2);
    }
    int comp = o1.asText().compareTo(o2.asText());
    if (comp == 0) {
        return Integer.compare(o1.hashCode(), o2.hashCode());
    }
    return comp;
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:17,代码来源:SerializationMatchers.java

示例5: doEquivalent

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
protected boolean doEquivalent(final JsonNode a, final JsonNode b) {
    /*
     * If both are numbers, delegate to the helper method
     */
    if (a.isNumber() && b.isNumber()) {
        return numEquals(a, b);
    }

    final JsonNodeType typeA = a.getNodeType();
    final JsonNodeType typeB = b.getNodeType();

    /*
     * If they are of different types, no dice
     */
    if (typeA != typeB) {
        return false;
    }

    /*
     * For all other primitive types than numbers, trust JsonNode
     */
    if (!a.isContainerNode()) {
        return a.equals(b);
    }

    /*
     * OK, so they are containers (either both arrays or objects due to the
     * test on types above). They are obviously not equal if they do not
     * have the same number of elements/members.
     */
    if (a.size() != b.size()) {
        return false;
    }

    /*
     * Delegate to the appropriate method according to their type.
     */
    return typeA == JsonNodeType.ARRAY ? arrayEquals(a, b) : objectEquals(a, b);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:41,代码来源:JsonNumEquals.java

示例6: numEquals

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static boolean numEquals(final JsonNode a, final JsonNode b) {
    /*
     * If both numbers are integers, delegate to JsonNode.
     */
    if (a.isIntegralNumber() && b.isIntegralNumber()) {
        return a.equals(b);
    }

    /*
     * Otherwise, compare decimal values.
     */
    return a.decimalValue().compareTo(b.decimalValue()) == 0;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:14,代码来源:JsonNumEquals.java

示例7: pathAll

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * PathAll matcher that checks if each element of the final
 * result matches the expected result.
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if all elements of the final result matches
 *         the expected result, False otherwise
 */
public static boolean pathAll(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (!element.equals(expectedResult)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:26,代码来源:AcceptorPathMatcher.java

示例8: sameJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private boolean sameJson(String s1, String s2) {
    try {
        JsonNode tree1 = MAPPER.readTree(s1);
        JsonNode tree2 = MAPPER.readTree(s2);
        return tree1.equals(tree2);
    } catch (IOException e) {
        System.out.println("Exception: " + e);
    }
    return false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:CoreModelCacheTest.java

示例9: pathAll

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * PathAll matcher that checks if each element of the final
 * result matches the expected result
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if all elements of the final result matches
 * the expected result, False otherwise
 */
public static boolean pathAll(JsonNode expectedResult, JsonNode finalResult) {
    if (finalResult.isNull()) {
        return false;
    }
    if (!finalResult.isArray()) {
        throw new RuntimeException("Expected an array");
    }
    for (JsonNode element : finalResult) {
        if (!element.equals(expectedResult)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:AcceptorPathMatcher.java

示例10: path

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Path matcher that checks if the final result
 * matches the expected result.
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if the final result matches the expected result,
 *         False otherwise
 */
public static boolean path(JsonNode expectedResult, JsonNode finalResult) {
    return finalResult.equals(expectedResult);
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:15,代码来源:AcceptorPathMatcher.java

示例11: path

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Path matcher that checks if the final result
 * matches the expected result
 *
 * @param expectedResult Expected result given by the waiter definition
 * @param finalResult    Final result of the resource got by the execution
 *                       of the JmesPath expression given by the waiter
 *                       definition
 * @return True if the final result matches the expected result,
 * False otherwise
 */
public static boolean path(JsonNode expectedResult, JsonNode finalResult) {
    return finalResult.equals(expectedResult);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:15,代码来源:AcceptorPathMatcher.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。