Put a key/value pair in the JSONObject, but only if the key and the value are both non-null, and only if there is not already a member with that name. @param key @param value @return this. @throws RuntimeException if the key is a duplicate, or if #put(String,Object) throws.
(String key, Object value)
| 1351 | * {@link #put(String,Object)} throws. |
| 1352 | */ |
| 1353 | private JSONObject putOnce(String key, Object value) { |
| 1354 | if (key != null && value != null) { |
| 1355 | if (this.opt(key) != null) { |
| 1356 | throw new RuntimeException("Duplicate key \"" + key + "\""); |
| 1357 | } |
| 1358 | this.put(key, value); |
| 1359 | } |
| 1360 | return this; |
| 1361 | } |
| 1362 | |
| 1363 | |
| 1364 | // /** |
no test coverage detected