Debian Codegraph @

src/jakarta/json/JsonPatchBuilder.java

raw symbols SCIP
1 /*
2 * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
9 * Licenses when the conditions for such availability set forth in the
10 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11 * version 2 with the GNU Classpath Exception, which is available at
12 * https://www.gnu.org/software/classpath/license.html.
13 *
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15 */
16
17 package jakarta.json;
18
19 /**
20 * A builder for constructing a JSON Patch as defined by
21 * <a href="http://tools.ietf.org/html/rfc6902">RFC 6902</a> by adding
22 * JSON Patch operations incrementally.
23 * <p>
24 * The following illustrates the approach.
25 * <pre>
26 * JsonPatchBuilder builder = Json.createPatchBuilder();
27 * JsonPatch patch = builder.add("/John/phones/office", "1234-567")
28 * .remove("/Amy/age")
29 * .build();
30 * </pre>
31 * The result is equivalent to the following JSON Patch.
32 * <pre>
33 * [
34 * {"op" = "add", "path" = "/John/phones/office", "value" = "1234-567"},
35 * {"op" = "remove", "path" = "/Amy/age"}
36 * ] </pre>
37 *
38 * @see <a href="http://tools.ietf.org/html/rfc6902">RFC 6902</a>
39 *
40 * @since 1.1
41 */
42 public interface JsonPatchBuilder {
43
44 /**
45 * Adds an "add" JSON Patch operation.
46 *
47 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer.
48 * @param value the "value" member of the operation
49 * @return this JsonPatchBuilder
50 */
51 JsonPatchBuilder add(String path, JsonValue value);
52
53 /**
54 * Adds an "add" JSON Patch operation.
55 *
56 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer.
57 * @param value the "value" member of the operation
58 * @return this JsonPatchBuilder
59 */
60 JsonPatchBuilder add(String path, String value);
61
62 /**
63 * Adds an "add" JSON Patch operation.
64 *
65 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer.
66 * @param value the "value" member of the operation
67 * @return this JsonPatchBuilder
68 */
69 JsonPatchBuilder add(String path, int value);
70
71 /**
72 * Adds an "add" JSON Patch operation.
73 *
74 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer.
75 * @param value the "value" member of the operation
76 * @return this JsonPatchBuilder
77 */
78 JsonPatchBuilder add(String path, boolean value);
79
80 /**
81 * Adds a "remove" JSON Patch operation.
82 *
83 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer.
84 * @return this JsonPatchBuilder
85 */
86 JsonPatchBuilder remove(String path);
87
88 /**
89 * Adds a "replace" JSON Patch operation.
90 *
91 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer.
92 * @param value the "value" member of the operation
93 * @return this JsonPatchBuilder
94 */
95 JsonPatchBuilder replace(String path, JsonValue value);
96
97 /**
98 * Adds a "replace" JSON Patch operation.
99 *
100 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
101 * @param value the "value" member of the operation
102 * @return this JsonPatchBuilder
103 */
104 JsonPatchBuilder replace(String path, String value);
105
106 /**
107 * Adds a "replace" JSON Patch operation.
108 *
109 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
110 * @param value the "value" member of the operation
111 * @return this JsonPatchBuilder
112 */
113 JsonPatchBuilder replace(String path, int value);
114
115 /**
116 * Adds a "replace" JSON Patch operation.
117 *
118 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
119 * @param value the "value" member of the operation
120 * @return this JsonPatchBuilder
121 */
122 JsonPatchBuilder replace(String path, boolean value);
123
124 /**
125 * Adds a "move" JSON Patch operation.
126 *
127 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
128 * @param from the "from" member of the operation
129 * @return this JsonPatchBuilder
130 */
131 JsonPatchBuilder move(String path, String from);
132
133 /**
134 * Adds a "copy" JSON Patch operation.
135 *
136 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
137 * @param from the "from" member of the operation
138 * @return this JsonPatchBuilder
139 */
140 JsonPatchBuilder copy(String path, String from);
141
142 /**
143 * Adds a "test" JSON Patch operation.
144 *
145 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
146 * @param value the "value" member of the operation
147 * @return this JsonPatchBuilder
148 */
149 JsonPatchBuilder test(String path, JsonValue value);
150
151 /**
152 * Adds a "test" JSON Patch operation.
153 *
154 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
155 * @param value the "value" member of the operation
156 * @return this JsonPatchBuilder
157 */
158 JsonPatchBuilder test(String path, String value);
159
160 /**
161 * Adds a "test" JSON Patch operation.
162 *
163 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
164 * @param value the "value" member of the operation
165 * @return this JsonPatchBuilder
166 */
167 JsonPatchBuilder test(String path, int value);
168
169 /**
170 * Adds a "test" JSON Patch operation.
171 *
172 * @param path the "path" member of the operation. Must be a valid escaped JSON-Pointer string.
173 * @param value the "value" member of the operation
174 * @return this JsonPatchBuilder
175 */
176 JsonPatchBuilder test(String path, boolean value);
177
178
179 /**
180 * Returns the JSON Patch.
181 *
182 * @return a JSON Patch
183 */
184 JsonPatch build();
185
186 }