Class JsonPatch.Builder

java.lang.Object
cloud.opencode.base.json.patch.JsonPatch.Builder
Enclosing class:
JsonPatch

public static final class JsonPatch.Builder extends Object
Builder for JsonPatch. JsonPatch 的构建器。
Since:
JDK 25, opencode-base-json V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • add

      public JsonPatch.Builder add(String path, JsonNode value)
      Adds an add operation. 添加一个 add 操作。
      Parameters:
      path - the JSON Pointer path - JSON Pointer 路径
      value - the value to add - 要添加的值
      Returns:
      this builder - 此构建器
    • remove

      public JsonPatch.Builder remove(String path)
      Adds a remove operation. 添加一个 remove 操作。
      Parameters:
      path - the JSON Pointer path - JSON Pointer 路径
      Returns:
      this builder - 此构建器
    • replace

      public JsonPatch.Builder replace(String path, JsonNode value)
      Adds a replace operation. 添加一个 replace 操作。
      Parameters:
      path - the JSON Pointer path - JSON Pointer 路径
      value - the new value - 新值
      Returns:
      this builder - 此构建器
    • move

      public JsonPatch.Builder move(String from, String path)
      Adds a move operation. 添加一个 move 操作。
      Parameters:
      from - the source path - 源路径
      path - the target path - 目标路径
      Returns:
      this builder - 此构建器
    • copy

      public JsonPatch.Builder copy(String from, String path)
      Adds a copy operation. 添加一个 copy 操作。
      Parameters:
      from - the source path - 源路径
      path - the target path - 目标路径
      Returns:
      this builder - 此构建器
    • test

      public JsonPatch.Builder test(String path, JsonNode expected)
      Adds a test operation. 添加一个 test 操作。
      Parameters:
      path - the JSON Pointer path - JSON Pointer 路径
      expected - the expected value - 预期值
      Returns:
      this builder - 此构建器
    • build

      public JsonPatch build()
      Builds the patch. 构建补丁。
      Returns:
      the patch - 补丁