Skip to content

Commit 6c0209e

Browse files
committed
Add DataView#set with primitive overloads
1 parent 8592ac7 commit 6c0209e

2 files changed

Lines changed: 264 additions & 0 deletions

File tree

src/main/java/org/spongepowered/api/data/persistence/DataContainer.java

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,91 @@ static DataContainer createNew(SafetyMode safety) {
5858
@Override
5959
DataContainer set(DataQuery path, Object value);
6060

61+
@Override
62+
default DataContainer set(DataQuery path, String value) {
63+
return this.set(path, (Object) value);
64+
}
65+
66+
@Override
67+
default DataContainer set(DataQuery path, boolean value) {
68+
return this.set(path, (Object) value);
69+
}
70+
71+
@Override
72+
default DataContainer set(DataQuery path, byte value) {
73+
return this.set(path, (Object) value);
74+
}
75+
76+
@Override
77+
default DataContainer set(DataQuery path, short value) {
78+
return this.set(path, (Object) value);
79+
}
80+
81+
@Override
82+
default DataContainer set(DataQuery path, int value) {
83+
return this.set(path, (Object) value);
84+
}
85+
86+
@Override
87+
default DataContainer set(DataQuery path, long value) {
88+
return this.set(path, (Object) value);
89+
}
90+
91+
@Override
92+
default DataContainer set(DataQuery path, float value) {
93+
return this.set(path, (Object) value);
94+
}
95+
96+
@Override
97+
default DataContainer set(DataQuery path, double value) {
98+
return this.set(path, (Object) value);
99+
}
100+
61101
@Override
62102
default DataContainer set(String key, Object value) {
63103
return this.set(DataQuery.of(key), value);
64104
}
65105

106+
@Override
107+
default DataContainer set(String key, String value) {
108+
return this.set(key, (Object) value);
109+
}
110+
111+
@Override
112+
default DataContainer set(String key, boolean value) {
113+
return this.set(key, (Object) value);
114+
}
115+
116+
@Override
117+
default DataContainer set(String key, byte value) {
118+
return this.set(key, (Object) value);
119+
}
120+
121+
@Override
122+
default DataContainer set(String key, short value) {
123+
return this.set(key, (Object) value);
124+
}
125+
126+
@Override
127+
default DataContainer set(String key, int value) {
128+
return this.set(key, (Object) value);
129+
}
130+
131+
@Override
132+
default DataContainer set(String key, long value) {
133+
return this.set(key, (Object) value);
134+
}
135+
136+
@Override
137+
default DataContainer set(String key, float value) {
138+
return this.set(key, (Object) value);
139+
}
140+
141+
@Override
142+
default DataContainer set(String key, double value) {
143+
return this.set(key, (Object) value);
144+
}
145+
66146
@Override
67147
DataContainer remove(DataQuery path);
68148
}

src/main/java/org/spongepowered/api/data/persistence/DataView.java

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,102 @@ default Stream<Map.Entry<String, Object>> streamRootValues() {
177177
*/
178178
DataView set(DataQuery path, Object value);
179179

180+
/**
181+
* Sets the given String value according to the given path relative to
182+
* this {@link DataView}'s path.
183+
*
184+
* @param path The path of the string to set
185+
* @param value The value of the data
186+
* @return This view, for chaining
187+
*/
188+
default DataView set(DataQuery path, String value) {
189+
return this.set(path, (Object) value);
190+
}
191+
192+
/**
193+
* Sets the given boolean value according to the given path relative to
194+
* this {@link DataView}'s path.
195+
*
196+
* @param path The path of the boolean to set
197+
* @param value The value of the data
198+
* @return This view, for chaining
199+
*/
200+
default DataView set(DataQuery path, boolean value) {
201+
return this.set(path, (Object) value);
202+
}
203+
204+
/**
205+
* Sets the given byte value according to the given path relative to
206+
* this {@link DataView}'s path.
207+
*
208+
* @param path The path of the byte to set
209+
* @param value The value of the data
210+
* @return This view, for chaining
211+
*/
212+
default DataView set(DataQuery path, byte value) {
213+
return this.set(path, (Object) value);
214+
}
215+
216+
/**
217+
* Sets the given short value according to the given path relative to
218+
* this {@link DataView}'s path.
219+
*
220+
* @param path The path of the short to set
221+
* @param value The value of the data
222+
* @return This view, for chaining
223+
*/
224+
default DataView set(DataQuery path, short value) {
225+
return this.set(path, (Object) value);
226+
}
227+
228+
/**
229+
* Sets the given int value according to the given path relative to
230+
* this {@link DataView}'s path.
231+
*
232+
* @param path The path of the int to set
233+
* @param value The value of the data
234+
* @return This view, for chaining
235+
*/
236+
default DataView set(DataQuery path, int value) {
237+
return this.set(path, (Object) value);
238+
}
239+
240+
/**
241+
* Sets the given long value according to the given path relative to
242+
* this {@link DataView}'s path.
243+
*
244+
* @param path The path of the long to set
245+
* @param value The value of the data
246+
* @return This view, for chaining
247+
*/
248+
default DataView set(DataQuery path, long value) {
249+
return this.set(path, (Object) value);
250+
}
251+
252+
/**
253+
* Sets the given float value according to the given path relative to
254+
* this {@link DataView}'s path.
255+
*
256+
* @param path The path of the float to set
257+
* @param value The value of the data
258+
* @return This view, for chaining
259+
*/
260+
default DataView set(DataQuery path, float value) {
261+
return this.set(path, (Object) value);
262+
}
263+
264+
/**
265+
* Sets the given double value according to the given path relative to
266+
* this {@link DataView}'s path.
267+
*
268+
* @param path The path of the double to set
269+
* @param value The value of the data
270+
* @return This view, for chaining
271+
*/
272+
default DataView set(DataQuery path, double value) {
273+
return this.set(path, (Object) value);
274+
}
275+
180276
/**
181277
* Sets the given Object value to this {@link DataView}'s key.
182278
*
@@ -188,6 +284,94 @@ default DataView set(String key, Object value) {
188284
return this.set(DataQuery.of(key), value);
189285
}
190286

287+
/**
288+
* Sets the given String value to this {@link DataView}'s key.
289+
*
290+
* @param key The key of the object to set
291+
* @param value The value of the data
292+
* @return This view, for chaining
293+
*/
294+
default DataView set(String key, String value) {
295+
return this.set(key, (Object) value);
296+
}
297+
298+
/**
299+
* Sets the given boolean value to this {@link DataView}'s key.
300+
*
301+
* @param key The key of the object to set
302+
* @param value The value of the data
303+
* @return This view, for chaining
304+
*/
305+
default DataView set(String key, boolean value) {
306+
return this.set(key, (Object) value);
307+
}
308+
309+
/**
310+
* Sets the given byte value to this {@link DataView}'s key.
311+
*
312+
* @param key The key of the object to set
313+
* @param value The value of the data
314+
* @return This view, for chaining
315+
*/
316+
default DataView set(String key, byte value) {
317+
return this.set(key, (Object) value);
318+
}
319+
320+
/**
321+
* Sets the given short value to this {@link DataView}'s key.
322+
*
323+
* @param key The key of the object to set
324+
* @param value The value of the data
325+
* @return This view, for chaining
326+
*/
327+
default DataView set(String key, short value) {
328+
return this.set(key, (Object) value);
329+
}
330+
331+
/**
332+
* Sets the given int value to this {@link DataView}'s key.
333+
*
334+
* @param key The key of the object to set
335+
* @param value The value of the data
336+
* @return This view, for chaining
337+
*/
338+
default DataView set(String key, int value) {
339+
return this.set(key, (Object) value);
340+
}
341+
342+
/**
343+
* Sets the given long value to this {@link DataView}'s key.
344+
*
345+
* @param key The key of the object to set
346+
* @param value The value of the data
347+
* @return This view, for chaining
348+
*/
349+
default DataView set(String key, long value) {
350+
return this.set(key, (Object) value);
351+
}
352+
353+
/**
354+
* Sets the given float value to this {@link DataView}'s key.
355+
*
356+
* @param key The key of the object to set
357+
* @param value The value of the data
358+
* @return This view, for chaining
359+
*/
360+
default DataView set(String key, float value) {
361+
return this.set(key, (Object) value);
362+
}
363+
364+
/**
365+
* Sets the given double value to this {@link DataView}'s key.
366+
*
367+
* @param key The key of the object to set
368+
* @param value The value of the data
369+
* @return This view, for chaining
370+
*/
371+
default DataView set(String key, double value) {
372+
return this.set(key, (Object) value);
373+
}
374+
191375
/**
192376
* Removes the data associated to the given path relative to this
193377
* {@link DataView}'s path.

0 commit comments

Comments
 (0)