/** * Adds a "copy" JSON Patch operation. * @param path the "path" member of the operation * @param from the "from" member of the operation * @return this JsonPatchBuilder */ @Override public JsonPatchBuilder copy(String path, String from) { builder.add(Json.createObjectBuilder() .add("op", Operation.COPY.operationName()) .add("path", path) .add("from", from) ); return this; }
/** * Returns the enum constant with the specified name. * * @param operationName {@code operationName} to convert to the enum constant. * @return the enum constant for given {@code operationName} * @throws JsonException if given {@code operationName} is not recognized */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("Illegal value for the operationName of the JSON patch operation: " + operationName); } }
switch (Operation.fromOperationName(operation.getString("op"))) { case ADD: return pointer.add(target, getValue(operation));
switch (Operation.fromOperationName(operation.getString("op"))) { case ADD: return pointer.add(target, getValue(operation));
switch (Operation.fromOperationName(operation.getString("op"))) { case ADD: return pointer.add(target, getValue(operation));
switch (Operation.fromOperationName(operation.getString("op"))) { case ADD: return pointer.add(target, getValue(operation));
switch (Operation.fromOperationName(operation.getString("op"))) { case ADD: return pointer.add(target, getValue(operation));
/** * Returns the {@link Operation} for the given {@code operationName}. If no {@link Operation} * is present, a {@link JsonException} will be thrown. * * @param operationName {@code operationName} to convert to the enum constant. * * @return the {@link Operation Operation-constant} for given {@code operationName} * * @throws JsonException if no {@link Operation} has been found for the given {@code operationName} */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("unknown value for the operationName of the JSON patch operation: " + operationName); } }
/** * Returns the {@link Operation} for the given {@code operationName}. If no {@link Operation} * is present, a {@link JsonException} will be thrown. * * @param operationName {@code operationName} to convert to the enum constant. * * @return the {@link Operation Operation-constant} for given {@code operationName} * * @throws JsonException if no {@link Operation} has been found for the given {@code operationName} */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("unknown value for the operationName of the JSON patch operation: " + operationName); } }
JsonPatchBuilderImpl(final JsonProvider provider, JsonArray initialData) { this.provider = provider; this.operations = new ArrayList<>(initialData.size()); for (JsonValue value : initialData) { JsonObject operation = (JsonObject) value; JsonPatch.Operation op = JsonPatch.Operation.fromOperationName(operation.getString("op")); String path = operation.getString("path"); String from = operation.getString("from", null); JsonValue jsonValue = operation.get("value"); this.operations.add(new JsonPatchImpl.PatchValue(provider, op, path, from, jsonValue)); } }
/** * Returns the {@link Operation} for the given {@code operationName}. If no {@link Operation} * is present, a {@link JsonException} will be thrown. * * @param operationName {@code operationName} to convert to the enum constant. * * @return the {@link Operation Operation-constant} for given {@code operationName} * * @throws JsonException if no {@link Operation} has been found for the given {@code operationName} */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("unknown value for the operationName of the JSON patch operation: " + operationName); } }
/** * Returns the enum constant with the specified name. * * @param operationName {@code operationName} to convert to the enum constant. * @return the enum constant for given {@code operationName} * @throws JsonException if given {@code operationName} is not recognized */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("Illegal value for the operationName of the JSON patch operation: " + operationName); } }
/** * Returns the enum constant with the specified name. * * @param operationName {@code operationName} to convert to the enum constant. * @return the enum constant for given {@code operationName} * @throws JsonException if given {@code operationName} is not recognized */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("Illegal value for the operationName of the JSON patch operation: " + operationName); } }
/** * Returns the enum constant with the specified name. * * @param operationName {@code operationName} to convert to the enum constant. * @return the enum constant for given {@code operationName} * @throws JsonException if given {@code operationName} is not recognized */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("Illegal value for the operationName of the JSON patch operation: " + operationName); } }
/** * Returns the enum constant with the specified name. * * @param operationName {@code operationName} to convert to the enum constant. * @return the enum constant for given {@code operationName} * @throws JsonException if given {@code operationName} is not recognized */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("Illegal value for the operationName of the JSON patch operation: " + operationName); } }
/** * Returns the enum constant with the specified name. * * @param operationName {@code operationName} to convert to the enum constant. * @return the enum constant for given {@code operationName} * @throws JsonException if given {@code operationName} is not recognized */ public static Operation fromOperationName(String operationName) { for (Operation op : values()) { if (op.operationName().equalsIgnoreCase(operationName)) { return op; } } throw new JsonException("Illegal value for the operationName of the JSON patch operation: " + operationName); } }
JsonPatchBuilderImpl(final JsonProvider provider, JsonArray initialData) { this.provider = provider; this.operations = new ArrayList<>(initialData.size()); for (JsonValue value : initialData) { JsonObject operation = (JsonObject) value; JsonPatch.Operation op = JsonPatch.Operation.fromOperationName(operation.getString("op")); String path = operation.getString("path"); String from = operation.getString("from", null); JsonValue jsonValue = operation.get("value"); this.operations.add(new JsonPatchImpl.PatchValue(provider, op, path, from, jsonValue)); } }
/** * Adds a "replace" JSON Patch operation. * @param path the "path" member of the operation * @param value the "value" member of the operation * @return this JsonPatchBuilder */ @Override public JsonPatchBuilder replace(String path, int value) { builder.add(Json.createObjectBuilder() .add("op", Operation.REPLACE.operationName()) .add("path", path) .add("value", value) ); return this; }
/** * Adds a "replace" JSON Patch operation. * @param path the "path" member of the operation * @param value the "value" member of the operation * @return this JsonPatchBuilder */ @Override public JsonPatchBuilder replace(String path, JsonValue value) { builder.add(Json.createObjectBuilder() .add("op", Operation.REPLACE.operationName()) .add("path", path) .add("value", value) ); return this; }
/** * Adds an "add" JSON Patch operation. * @param path the "path" member of the operation * @param value the "value" member of the operation * @return this JsonPatchBuilder */ @Override public JsonPatchBuilder add(String path, JsonValue value) { builder.add(Json.createObjectBuilder() .add("op", Operation.ADD.operationName()) .add("path", path) .add("value", value) ); return this; }