Skip to content

Commit e96e5f7

Browse files
authored
Added additional requireNonNull calls and javadoc to clarify MapValue behavior related to null values
1 parent 839b399 commit e96e5f7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

driver/src/main/java/oracle/nosql/driver/values/MapValue.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
* schema field names are treated as case-insensitive. If a MapValue
4040
* represents JSON, field names are case-sensitive.
4141
* </p>
42+
* MapValue does not support put of Java null values. If a "null" JSON value is
43+
* desired it is possible to put a {@link NullValue} instance using
44+
* "put(fieldName, NullValue.getInstance())"
4245
* <p>
4346
* When a MapValue is received on output the value will always conform to
4447
* the schema of the table from which the value was received or the implied
@@ -289,6 +292,7 @@ public MapValue put(String name, double value) {
289292
* @return this
290293
*/
291294
public MapValue put(String name, BigDecimal value) {
295+
requireNonNull(value, "MapValue.put: value must be non-null");
292296
return put(name, new NumberValue(value));
293297
}
294298

@@ -303,6 +307,7 @@ public MapValue put(String name, BigDecimal value) {
303307
* @return this
304308
*/
305309
public MapValue put(String name, String value) {
310+
requireNonNull(value, "MapValue.put: value must be non-null");
306311
return put(name, new StringValue(value));
307312
}
308313

@@ -331,6 +336,7 @@ public MapValue put(String name, boolean value) {
331336
* @return this
332337
*/
333338
public MapValue put(String name, byte[] value) {
339+
requireNonNull(value, "MapValue.put: value must be non-null");
334340
return put(name, new BinaryValue(value));
335341
}
336342

@@ -345,6 +351,7 @@ public MapValue put(String name, byte[] value) {
345351
* @return this
346352
*/
347353
public MapValue put(String name, Timestamp value) {
354+
requireNonNull(value, "MapValue.put: value must be non-null");
348355
return put(name, new TimestampValue(value));
349356
}
350357

@@ -367,6 +374,8 @@ public MapValue put(String name, Timestamp value) {
367374
public MapValue putFromJson(String name,
368375
String jsonString,
369376
JsonOptions options) {
377+
requireNonNull(jsonString,
378+
"MapValue.putFromJson: JSON string must be non-null");
370379
return put(name, JsonUtils.createValueFromJson(jsonString, options));
371380
}
372381

0 commit comments

Comments
 (0)