From b00870b2210587b44b2065abd8e5f261d666bef8 Mon Sep 17 00:00:00 2001 From: Aidan Follestad Date: Thu, 24 Aug 2017 11:06:40 -0500 Subject: [PATCH] 1.4.14 --- src/main/java/com/afollestad/ason/Ason.java | 16 ++++---- .../com/afollestad/ason/AsonSerializer.java | 4 +- .../com/afollestad/ason/AsonArrayTest.java | 2 +- .../afollestad/ason/AsonSerializeTest.java | 39 ++++++++----------- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/afollestad/ason/Ason.java b/src/main/java/com/afollestad/ason/Ason.java index f59c7fb..a2c3077 100644 --- a/src/main/java/com/afollestad/ason/Ason.java +++ b/src/main/java/com/afollestad/ason/Ason.java @@ -20,9 +20,7 @@ import org.json.JSONException; import org.json.JSONObject; -/** - * @author Aidan Follestad (afollestad) - */ +/** @author Aidan Follestad (afollestad) */ @SuppressWarnings({"WeakerAccess", "unused", "unchecked", "SameParameterValue"}) public class Ason { @@ -109,8 +107,8 @@ public static T deserialize(@Nullable AsonArray json, @NonNls Class cls) return deserialize(json, cls, false); } - public static T deserialize(@Nullable AsonArray json, @NonNls Class cls, - boolean recursive) { + public static T deserialize( + @Nullable AsonArray json, @NonNls Class cls, boolean recursive) { return AsonSerializer.get().deserializeArray(json, cls, recursive); } @@ -118,8 +116,8 @@ public static List deserializeList(@Nullable String json, @NotNull Class< return deserializeList(json, cls, false); } - public static List deserializeList(@Nullable String json, @NotNull Class cls, - boolean recursive) { + public static List deserializeList( + @Nullable String json, @NotNull Class cls, boolean recursive) { AsonArray array = new AsonArray(json); return AsonSerializer.get().deserializeList(array, cls, recursive); } @@ -128,8 +126,8 @@ public static List deserializeList(@Nullable AsonArray json, @NotNull Cla return deserializeList(json, cls, false); } - public static List deserializeList(@Nullable AsonArray json, @NotNull Class cls, - boolean recursive) { + public static List deserializeList( + @Nullable AsonArray json, @NotNull Class cls, boolean recursive) { return AsonSerializer.get().deserializeList(json, cls, recursive); } diff --git a/src/main/java/com/afollestad/ason/AsonSerializer.java b/src/main/java/com/afollestad/ason/AsonSerializer.java index 38c9211..d6d4b8a 100644 --- a/src/main/java/com/afollestad/ason/AsonSerializer.java +++ b/src/main/java/com/afollestad/ason/AsonSerializer.java @@ -19,9 +19,7 @@ import org.json.JSONArray; import org.json.JSONObject; -/** - * @author Aidan Follestad (afollestad) - */ +/** @author Aidan Follestad (afollestad) */ @SuppressWarnings({"unchecked", "WeakerAccess", "unused"}) class AsonSerializer { diff --git a/src/test/java/com/afollestad/ason/AsonArrayTest.java b/src/test/java/com/afollestad/ason/AsonArrayTest.java index e90d807..e87c496 100644 --- a/src/test/java/com/afollestad/ason/AsonArrayTest.java +++ b/src/test/java/com/afollestad/ason/AsonArrayTest.java @@ -174,7 +174,7 @@ public void test_array_in_array() { @Test public void test_array_in_array_deserialize() { AsonArray parent = - new AsonArray().add(new Integer[]{1, 2, 3, 4}, new Integer[]{5, 6, 7, 8}); + new AsonArray().add(new Integer[] {1, 2, 3, 4}, new Integer[] {5, 6, 7, 8}); assertEquals(2, parent.size()); Integer[] arrayOne = parent.get(0, Integer[].class); diff --git a/src/test/java/com/afollestad/ason/AsonSerializeTest.java b/src/test/java/com/afollestad/ason/AsonSerializeTest.java index be18f41..a50e73d 100644 --- a/src/test/java/com/afollestad/ason/AsonSerializeTest.java +++ b/src/test/java/com/afollestad/ason/AsonSerializeTest.java @@ -15,9 +15,7 @@ import org.json.JSONObject; import org.junit.Test; -/** - * @author Aidan Follestad (afollestad) - */ +/** @author Aidan Follestad (afollestad) */ public class AsonSerializeTest { // @@ -40,7 +38,7 @@ public void test_serialize() { @Test public void test_serialize_array() { - Person[] people = new Person[]{new Person(1, "Aidan", 22), new Person(2, "Nina", 22)}; + Person[] people = new Person[] {new Person(1, "Aidan", 22), new Person(2, "Nina", 22)}; AsonArray json = Ason.serializeArray(people); Ason one = json.getJsonObject(0); @@ -97,7 +95,7 @@ public void test_put_array_serialize() { @Test public void test_primitive_serialize() { - int[] ids = new int[]{1, 2, 3, 4}; + int[] ids = new int[] {1, 2, 3, 4}; AsonArray array = Ason.serializeArray(ids); assertEquals("[1,2,3,4]", array.toString()); } @@ -105,7 +103,7 @@ public void test_primitive_serialize() { @Test public void test_serialize_with_array() { Person2 person = new Person2(1); - person.family = new Person2[]{new Person2(2), new Person2(3), new Person2(4)}; + person.family = new Person2[] {new Person2(2), new Person2(3), new Person2(4)}; Ason ason = Ason.serialize(person); AsonArray array = ason.get("family"); @@ -308,7 +306,7 @@ public void test_serialize_ason_object_array() { @Test public void test_serialize_array_list_wrong_method() { try { - Ason.serialize(new int[]{1, 2, 3, 4}); + Ason.serialize(new int[] {1, 2, 3, 4}); assertFalse("No exception thrown when using serialize() on array!", false); } catch (IllegalArgumentException ignored) { } @@ -327,7 +325,7 @@ public void test_serialize_array_list_wrong_method() { @Test public void test_serialize_empty_array() { - AsonArray array = Ason.serializeArray(new int[]{}); + AsonArray array = Ason.serializeArray(new int[] {}); assertTrue(array.isEmpty()); } @@ -484,7 +482,7 @@ public void test_get_list_null() { @Test public void test_issue10_serialize() { Issue10Example data = new Issue10Example(); - data.item = new Object[]{1, 2, 3, 4}; + data.item = new Object[] {1, 2, 3, 4}; Ason ason = Ason.serialize(data); AsonArray array = ason.get("item"); @@ -500,7 +498,7 @@ public void test_issue10_deserialize() { Ason ason = new Ason("{\"item\": [1, 2, 3, 4]}"); Issue10Example result = Ason.deserialize(ason, Issue10Example.class); Object[] array = (Object[]) result.item; - assertTrue(Arrays.equals(new Integer[]{1, 2, 3, 4}, array)); + assertTrue(Arrays.equals(new Integer[] {1, 2, 3, 4}, array)); } @Test @@ -541,8 +539,8 @@ public void test_deserialize_all_nulls_to_primitive() { @Test public void test_deserialize_array_of_arrays() { - Integer[] one = new Integer[]{1, 2, 3, 4}; - Integer[] two = new Integer[]{5, 6, 7, 8}; + Integer[] one = new Integer[] {1, 2, 3, 4}; + Integer[] two = new Integer[] {5, 6, 7, 8}; AsonArray jsonArray = new AsonArray().add(one, two); Integer[][] matrix = AsonSerializer.get().deserializeArray(jsonArray, Integer[][].class); assertNotNull(matrix); @@ -606,8 +604,9 @@ public void test_deserialize_array_of_null_lists() { @Test public void test_recursive_deserialize() { - Ason ason = new Ason( - "{\"name\":\"Aidan\",\"power\":\"Flight\",\"_id\":2,\"age\":22,\"spouse\":{\"name\":\"Nina\",\"_id\":6,\"age\":22,\"spouse\":null}}"); + Ason ason = + new Ason( + "{\"name\":\"Aidan\",\"power\":\"Flight\",\"_id\":2,\"age\":22,\"spouse\":{\"name\":\"Nina\",\"_id\":6,\"age\":22,\"spouse\":null}}"); Superhero person = ason.deserialize(Superhero.class, true); assertEquals(person.name, "Aidan"); assertEquals(person.id, 2); @@ -624,11 +623,9 @@ static class Person { String name; int age; Person spouse; - @AsonIgnore - String gibberish = "Hello, world!"; + @AsonIgnore String gibberish = "Hello, world!"; - Person() { - } + Person() {} Person(int id, String name, int age) { this.id = id; @@ -648,8 +645,7 @@ static class Person2 { Person2[] family; - Person2() { - } + Person2() {} Person2(int id) { this(); @@ -679,8 +675,7 @@ private static class Superhero extends Person { String power; - Superhero() { - } + Superhero() {} Superhero(int id, String name, int age, String power) { super(id, name, age);