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)
| 1405 | * {@link #put(String,Object)} throws. |
| 1406 | */ |
| 1407 | private JSONObject putOnce(String key, Object value) { |
| 1408 | if (key != null && value != null) { |
| 1409 | if (this.opt(key) != null) { |
| 1410 | throw new RuntimeException("Duplicate key \"" + key + "\""); |
| 1411 | } |
| 1412 | this.put(key, value); |
| 1413 | } |
| 1414 | return this; |
| 1415 | } |
| 1416 | |
| 1417 | |
| 1418 | // /** |
no test coverage detected