1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
Description: Remove Nullable annotation
Nullable annnotation is just a warning that hints you can pass null to
methods that can take null arguments. Can be safely ignored since it
otherwise fails the build as it comes from libcore itself,
which we don't build.
Author: Raman Sarda <theloudspeaker@disroot.org>
Last-Update: 2020-05-18
--- a/json/src/main/java/org/json/JSONObject.java
+++ b/json/src/main/java/org/json/JSONObject.java
@@ -23,7 +23,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-import libcore.util.Nullable;
// Note: this class was written without inspecting the non-free org.json sourcecode.
@@ -256,7 +255,7 @@ public class JSONObject {
* infinities}.
* @return this object.
*/
- public JSONObject put( String name, @Nullable Object value) throws JSONException {
+ public JSONObject put( String name, Object value) throws JSONException {
if (value == null) {
nameValuePairs.remove(name);
return this;
@@ -273,7 +272,7 @@ public class JSONObject {
* Equivalent to {@code put(name, value)} when both parameters are non-null;
* does nothing otherwise.
*/
- public JSONObject putOpt(@Nullable String name, @Nullable Object value) throws JSONException {
+ public JSONObject putOpt(String name, Object value) throws JSONException {
if (name == null || value == null) {
return this;
}
@@ -300,7 +299,7 @@ public class JSONObject {
*/
// TODO: Change {@code append) to {@link #append} when append is
// unhidden.
- public JSONObject accumulate( String name, @Nullable Object value) throws JSONException {
+ public JSONObject accumulate( String name, Object value) throws JSONException {
Object current = nameValuePairs.get(checkName(name));
if (current == null) {
return put(name, value);
@@ -361,7 +360,7 @@ public class JSONObject {
* @return the value previously mapped by {@code name}, or null if there was
* no such mapping.
*/
- @Nullable public Object remove(@Nullable String name) {
+ public Object remove(String name) {
return nameValuePairs.remove(name);
}
@@ -369,7 +368,7 @@ public class JSONObject {
* Returns true if this object has no mapping for {@code name} or if it has
* a mapping whose value is {@link #NULL}.
*/
- public boolean isNull(@Nullable String name) {
+ public boolean isNull(String name) {
Object value = nameValuePairs.get(name);
return value == null || value == NULL;
}
@@ -378,7 +377,7 @@ public class JSONObject {
* Returns true if this object has a mapping for {@code name}. The mapping
* may be {@link #NULL}.
*/
- public boolean has(@Nullable String name) {
+ public boolean has(String name) {
return nameValuePairs.containsKey(name);
}
@@ -399,7 +398,7 @@ public class JSONObject {
* Returns the value mapped by {@code name}, or null if no such mapping
* exists.
*/
- @Nullable public Object opt(@Nullable String name) {
+ public Object opt(String name) {
return nameValuePairs.get(name);
}
@@ -423,7 +422,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a boolean or
* can be coerced to a boolean, or false otherwise.
*/
- public boolean optBoolean(@Nullable String name) {
+ public boolean optBoolean(String name) {
return optBoolean(name, false);
}
@@ -431,7 +430,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a boolean or
* can be coerced to a boolean, or {@code fallback} otherwise.
*/
- public boolean optBoolean(@Nullable String name, boolean fallback) {
+ public boolean optBoolean(String name, boolean fallback) {
Object object = opt(name);
Boolean result = JSON.toBoolean(object);
return result != null ? result : fallback;
@@ -457,7 +456,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a double or
* can be coerced to a double, or {@code NaN} otherwise.
*/
- public double optDouble(@Nullable String name) {
+ public double optDouble(String name) {
return optDouble(name, Double.NaN);
}
@@ -465,7 +464,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a double or
* can be coerced to a double, or {@code fallback} otherwise.
*/
- public double optDouble(@Nullable String name, double fallback) {
+ public double optDouble(String name, double fallback) {
Object object = opt(name);
Double result = JSON.toDouble(object);
return result != null ? result : fallback;
@@ -491,7 +490,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is an int or
* can be coerced to an int, or 0 otherwise.
*/
- public int optInt(@Nullable String name) {
+ public int optInt(String name) {
return optInt(name, 0);
}
@@ -499,7 +498,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is an int or
* can be coerced to an int, or {@code fallback} otherwise.
*/
- public int optInt(@Nullable String name, int fallback) {
+ public int optInt(String name, int fallback) {
Object object = opt(name);
Integer result = JSON.toInteger(object);
return result != null ? result : fallback;
@@ -528,7 +527,7 @@ public class JSONObject {
* can be coerced to a long, or 0 otherwise. Note that JSON represents numbers as doubles,
* so this is <a href="#lossy">lossy</a>; use strings to transfer numbers via JSON.
*/
- public long optLong(@Nullable String name) {
+ public long optLong(String name) {
return optLong(name, 0L);
}
@@ -538,7 +537,7 @@ public class JSONObject {
* numbers as doubles, so this is <a href="#lossy">lossy</a>; use strings to transfer
* numbers via JSON.
*/
- public long optLong(@Nullable String name, long fallback) {
+ public long optLong(String name, long fallback) {
Object object = opt(name);
Long result = JSON.toLong(object);
return result != null ? result : fallback;
@@ -563,7 +562,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists, coercing it if
* necessary, or the empty string if no such mapping exists.
*/
- public String optString(@Nullable String name) {
+ public String optString(String name) {
return optString(name, "");
}
@@ -571,7 +570,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists, coercing it if
* necessary, or {@code fallback} if no such mapping exists.
*/
- public String optString(@Nullable String name, String fallback) {
+ public String optString(String name, String fallback) {
Object object = opt(name);
String result = JSON.toString(object);
return result != null ? result : fallback;
@@ -597,7 +596,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONArray}, or null otherwise.
*/
- @Nullable public JSONArray optJSONArray(@Nullable String name) {
+ public JSONArray optJSONArray(String name) {
Object object = opt(name);
return object instanceof JSONArray ? (JSONArray) object : null;
}
@@ -622,7 +621,7 @@ public class JSONObject {
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}, or null otherwise.
*/
- @Nullable public JSONObject optJSONObject(@Nullable String name) {
+ public JSONObject optJSONObject(String name) {
Object object = opt(name);
return object instanceof JSONObject ? (JSONObject) object : null;
}
@@ -632,7 +631,7 @@ public class JSONObject {
* array contains null for names that aren't mapped. This method returns
* null if {@code names} is either null or empty.
*/
- @Nullable public JSONArray toJSONArray(@Nullable JSONArray names) throws JSONException {
+ public JSONArray toJSONArray(JSONArray names) throws JSONException {
JSONArray result = new JSONArray();
if (names == null) {
return null;
@@ -678,7 +677,7 @@ public class JSONObject {
* Returns an array containing the string names in this object. This method
* returns null if this object contains no mappings.
*/
- @Nullable public JSONArray names() {
+ public JSONArray names() {
return nameValuePairs.isEmpty()
? null
: new JSONArray(new ArrayList<String>(nameValuePairs.keySet()));
@@ -761,7 +760,7 @@ public class JSONObject {
* @param data the string to encode. Null will be interpreted as an empty
* string.
*/
- public static String quote(@Nullable String data) {
+ public static String quote(String data) {
if (data == null) {
return "\"\"";
}
@@ -788,7 +787,7 @@ public class JSONObject {
* Otherwise if the object is from a {@code java} package, returns the result of {@code toString}.
* If wrapping fails, returns null.
*/
- @Nullable public static Object wrap(@Nullable Object o) {
+ public static Object wrap(Object o) {
if (o == null) {
return NULL;
}
|