當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonNode.deepCopy方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.JsonNode.deepCopy方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonNode.deepCopy方法的具體用法?Java JsonNode.deepCopy怎麽用?Java JsonNode.deepCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


在下文中一共展示了JsonNode.deepCopy方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: apply

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
JsonNode apply(final JsonNode node) {
    JsonNode source = node.at(from);
    if (source.isMissingNode()) {
        throw new JsonPatchException("non-existent source path: " + from);
    }

    if (path.toString().isEmpty()) {
        return source;
    }

    final JsonNode targetParent = ensureTargetParent(node, path);
    source = source.deepCopy();
    return targetParent.isArray() ? AddOperation.addToArray(path, node, source)
                                  : AddOperation.addToObject(path, node, source);
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:17,代碼來源:CopyOperation.java

示例2: apply

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Applies this patch to a JSON value.
 *
 * @param node the value to apply the patch to
 * @return the patched JSON value
 * @throws JsonPatchException failed to apply patch
 * @throws NullPointerException input is null
 */
public JsonNode apply(final JsonNode node) {
    requireNonNull(node, "node");
    JsonNode ret = node.deepCopy();
    for (final JsonPatchOperation operation : operations) {
        ret = operation.apply(ret);
    }

    return ret;
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:18,代碼來源:JsonPatch.java

示例3: SafeReplaceOperation

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@JsonCreator
SafeReplaceOperation(@JsonProperty("path") final JsonPointer path,
                     @JsonProperty("oldValue") JsonNode oldValue,
                     @JsonProperty("value") JsonNode newValue) {
    super("safeReplace", path);
    this.oldValue = oldValue.deepCopy();
    this.newValue = newValue.deepCopy();
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:9,代碼來源:SafeReplaceOperation.java

示例4: apply

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Applies this schema rule to take the required code generation steps.
 * <p>
 * A Java {@link Enum} is created, with constants for each of the enum
 * values present in the schema. The enum name is derived from the nodeName,
 * and the enum type itself is created as an inner class of the owning type.
 * In the rare case that no owning type exists (the enum is the root of the
 * schema), then the enum becomes a public class in its own right.
 * <p>
 * The actual JSON value for each enum constant is held in a property called
 * "value" in the generated type. A static factory method
 * <code>fromValue(String)</code> is added to the generated enum, and the
 * methods are annotated to allow Jackson to marshal/unmarshal values
 * correctly.
 *
 * @param nodeName
 *            the name of the property which is an "enum"
 * @param node
 *            the enum node
 * @param container
 *            the class container (class or package) to which this enum
 *            should be added
 * @return the newly generated Java type that was created to represent the
 *         given enum
 */
@Override
public JType apply(String nodeName, JsonNode node, JClassContainer container, Schema schema) {

    JDefinedClass _enum;
    try {
        _enum = createEnum(node, nodeName, container);
    } catch (ClassAlreadyExistsException e) {
        return e.getExistingClass();
    }

    schema.setJavaTypeIfEmpty(_enum);

    if (node.has("javaInterfaces")) {
        addInterfaces(_enum, node.get("javaInterfaces"));
    }

    // copy our node; remove the javaType as it will throw off the TypeRule for our case
    ObjectNode typeNode = (ObjectNode)node.deepCopy();
    typeNode.remove("javaType");

    // If type is specified on the enum, get a type rule for it.  Otherwise, we're a string.
    // (This is different from the default of Object, which is why we don't do this for every case.)
    JType backingType = node.has("type") ?
            ruleFactory.getTypeRule().apply(nodeName, typeNode, container, schema) :
                container.owner().ref(String.class);

            JFieldVar valueField = addValueField(_enum, backingType);

            // override toString only if we have a sensible string to return
            if(isString(backingType)){
                addToString(_enum, valueField);
            }

            addValueMethod(_enum, valueField);

            addEnumConstants(node.path("enum"), _enum, node.path("javaEnumNames"), backingType);
            addFactoryMethod(_enum, backingType);

            return _enum;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:66,代碼來源:EnumRule.java

示例5: propertyNodeForComparisson

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
private static ObjectNode propertyNodeForComparisson(final JsonNode propertyDefinition) {
    final ObjectNode propertyDefinitionForComparisson = propertyDefinition.deepCopy();
    propertyDefinitionForComparisson.remove(Arrays.asList("tags", "componentProperty"));
    return propertyDefinitionForComparisson;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:6,代碼來源:DeploymentDescriptorIT.java

示例6: PathValueOperation

import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
 * Creates a new instance.
 *
 * @param op operation name
 * @param path affected path
 * @param value JSON value
 */
PathValueOperation(final String op, final JsonPointer path, final JsonNode value) {
    super(op, path);
    this.value = value.deepCopy();
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:12,代碼來源:PathValueOperation.java


注:本文中的com.fasterxml.jackson.databind.JsonNode.deepCopy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。