Updated JsonArray to support adding primitives directly via an overloaded "add(...)" method rather than having to always do "add(new JsonPrimitive(...))"
This commit is contained in:
parent
31ea72a29f
commit
6960ebc776
@ -49,6 +49,54 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified boolean to self.
|
||||
*
|
||||
* @param bool the boolean that needs to be added to the array.
|
||||
*/
|
||||
public void add(Boolean bool) {
|
||||
if (bool == null) {
|
||||
elements.add(JsonNull.INSTANCE);
|
||||
}
|
||||
elements.add(new JsonPrimitive(bool));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified character to self.
|
||||
*
|
||||
* @param character the character that needs to be added to the array.
|
||||
*/
|
||||
public void add(Character character) {
|
||||
if (character == null) {
|
||||
elements.add(JsonNull.INSTANCE);
|
||||
}
|
||||
elements.add(new JsonPrimitive(character));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified number to self.
|
||||
*
|
||||
* @param number the number that needs to be added to the array.
|
||||
*/
|
||||
public void add(Number number) {
|
||||
if (number == null) {
|
||||
elements.add(JsonNull.INSTANCE);
|
||||
}
|
||||
elements.add(new JsonPrimitive(number));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified string to self.
|
||||
*
|
||||
* @param string the string that needs to be added to the array.
|
||||
*/
|
||||
public void add(String string) {
|
||||
if (string == null) {
|
||||
elements.add(JsonNull.INSTANCE);
|
||||
}
|
||||
elements.add(new JsonPrimitive(string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified element to self.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user