MCPcopy Create free account
hub / github.com/MCBans/MCBans / putOnce

Method putOnce

src/main/java/com/mcbans/plugin/org/json/JSONObject.java:1112–1120  ·  view source on GitHub ↗

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 his. @throws JSONException if the key is a duplicate

(String key, Object value)

Source from the content-addressed store, hash-verified

1110 * @throws JSONException if the key is a duplicate
1111 */
1112 public JSONObject putOnce(String key, Object value) throws JSONException {
1113 if (key != null && value != null) {
1114 if (opt(key) != null) {
1115 throw new JSONException("Duplicate key \"" + key + "\"");
1116 }
1117 put(key, value);
1118 }
1119 return this;
1120 }
1121
1122
1123 /**

Callers 2

JSONObjectMethod · 0.95
keyMethod · 0.80

Calls 2

optMethod · 0.95
putMethod · 0.95

Tested by

no test coverage detected