|
3 | 3 | import java.util.ArrayList;
|
4 | 4 | import java.util.Iterator;
|
5 | 5 | import java.util.List;
|
| 6 | +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
6 | 7 |
|
7 | 8 | /**
|
8 | 9 | * A JSONObject is a custom data structure that represents a JSON object. It supports nested key-value pairs, arrays (as
|
@@ -165,6 +166,7 @@ public Number getAsNumber() {
|
165 | 166 | return value instanceof Number ? (Number) value : null;
|
166 | 167 | }
|
167 | 168 |
|
| 169 | + @SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL") |
168 | 170 | public Boolean getAsBoolean() {
|
169 | 171 | return value instanceof Boolean ? (Boolean) value : null;
|
170 | 172 | }
|
@@ -307,50 +309,6 @@ public String toString() {
|
307 | 309 | return String.join("\n", JSONStringifier.expandJson(JSONStringifier.stringifyJson(this)));
|
308 | 310 | }
|
309 | 311 |
|
310 |
| - /** |
311 |
| - * Format a value as it would appear within a JSON file. |
312 |
| - * |
313 |
| - * @param val |
314 |
| - * An Object to format |
315 |
| - * |
316 |
| - * @return A String for the value properly formatted for JSON |
317 |
| - */ |
318 |
| - private static String formatValue(Object val) { |
319 |
| - if (val == null) |
320 |
| - return "null"; |
321 |
| - if (val instanceof String) |
322 |
| - return String.format("\"%s\"", val); |
323 |
| - if (val instanceof JSONObject) |
324 |
| - return val.toString(); |
325 |
| - return val.toString(); |
326 |
| - } |
327 |
| - |
328 |
| - /** |
329 |
| - * Counts the number of items within the list, for use with formatting a String representation of a JSONObject. Most |
330 |
| - * types count as 1 entry, while instances of inner JSONObjects count as 3. Inner Arrays will be recursively |
331 |
| - * counted. |
332 |
| - * |
333 |
| - * @param list |
334 |
| - * A list to count the number of entries within |
335 |
| - * |
336 |
| - * @return An int count of the list's recursive calculated size |
337 |
| - * |
338 |
| - * @see JSONObject#toString() |
339 |
| - * @see JSONObject#SINGLE_LINE_ENTRIES_MAX |
340 |
| - */ |
341 |
| - private static int countInnerListEntries(List<?> list) { |
342 |
| - int entries = 0; |
343 |
| - for (Object o : list) { |
344 |
| - if (o instanceof JSONObject) |
345 |
| - entries += 3; |
346 |
| - else if (o instanceof List<?>) |
347 |
| - entries += countInnerListEntries((List<?>) o); |
348 |
| - else |
349 |
| - entries += 1; |
350 |
| - } |
351 |
| - return entries; |
352 |
| - } |
353 |
| - |
354 | 312 | @Override
|
355 | 313 | public int hashCode() {
|
356 | 314 | return this.toString().hashCode();
|
|
0 commit comments