aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDillon Dixon <dillondixon@gmail.com>2015-07-23 20:44:04 -0700
committerDillon Dixon <dillondixon@gmail.com>2015-07-23 20:44:04 -0700
commit6960ebc77684dd07125e39caefc140262b1fb76e (patch)
tree26450b47ead537867eb20bd9f3c2f1936376461b
parent31ea72a29f5aaf2fc3d59eefbf72d5eb68c8b176 (diff)
downloadandroid_external_gson-6960ebc77684dd07125e39caefc140262b1fb76e.tar.gz
android_external_gson-6960ebc77684dd07125e39caefc140262b1fb76e.tar.bz2
android_external_gson-6960ebc77684dd07125e39caefc140262b1fb76e.zip
Updated JsonArray to support adding primitives directly via an overloaded "add(...)" method rather than having to always do "add(new JsonPrimitive(...))"
-rw-r--r--gson/src/main/java/com/google/gson/JsonArray.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/gson/src/main/java/com/google/gson/JsonArray.java b/gson/src/main/java/com/google/gson/JsonArray.java
index c18f47f5..9e5be6c2 100644
--- a/gson/src/main/java/com/google/gson/JsonArray.java
+++ b/gson/src/main/java/com/google/gson/JsonArray.java
@@ -50,6 +50,54 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
}
/**
+ * 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.
*
* @param element the element that needs to be added to the array.