Browse Source

fixed some json issues; added yoda time support; swtiched dbo to automatic de/serialization

tags/v1.0.0
Robin Thoni 7 years ago
parent
commit
0478a3fa91

+ 0
- 1
app/build.gradle View File

@@ -46,7 +46,6 @@ dependencies {
46 46
     apt 'com.jakewharton:butterknife-compiler:8.0.1'
47 47
     compile project(path: ':luticateutils')
48 48
     compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
49
-    compile 'net.danlew:android.joda:2.9.4.2'
50 49
     compile 'com.google.firebase:firebase-ads:9.6.1'
51 50
     compile 'com.facebook.android:facebook-android-sdk:4.5.0'
52 51
     compile 'com.github.simbiose:Encryption:1.4.0'

+ 3
- 3
app/src/main/java/com/rthoni/stssaguenay/business/STSBusiness.java View File

@@ -52,7 +52,7 @@ public class STSBusiness {
52 52
                 dbo.fromJson(json.getJSONObject(i));
53 53
                 dbos.add(dbo);
54 54
             }
55
-        } catch (JSONException e) {
55
+        } catch (Exception e) {
56 56
             e.printStackTrace();
57 57
         }
58 58
         return dbos;
@@ -73,9 +73,9 @@ public class STSBusiness {
73 73
         if (str != null) {
74 74
             UserDbo user = new UserDbo();
75 75
             try {
76
-                user.fromJson(new JSONObject(str));
76
+                user.fromString(str);
77 77
                 return user;
78
-            } catch (JSONException e) {
78
+            } catch (Exception e) {
79 79
                 e.printStackTrace();
80 80
             }
81 81
         }

+ 2
- 2
app/src/main/java/com/rthoni/stssaguenay/business/UsersSettingsBusiness.java View File

@@ -29,8 +29,8 @@ public class UsersSettingsBusiness {
29 29
 
30 30
         UsersSettingsDbo settings = new UsersSettingsDbo();
31 31
         try {
32
-            settings.fromJson(new JSONObject(data));
33
-        } catch (JSONException e) {
32
+            settings.fromString(data);
33
+        } catch (Exception e) {
34 34
             e.printStackTrace();
35 35
             return null;
36 36
         }

+ 2
- 1
app/src/main/java/com/rthoni/stssaguenay/dataaccess/SchedulesDataAccess.java View File

@@ -3,6 +3,7 @@ package com.rthoni.stssaguenay.dataaccess;
3 3
 import com.luticate.utils.business.LuPromise;
4 4
 import com.luticate.utils.dataaccess.LuDataAccess;
5 5
 import com.luticate.utils.dbo.LuDataAccessConfigDbo;
6
+import com.luticate.utils.dbo.LuDbo;
6 7
 import com.rthoni.stssaguenay.dbo.UserFavouriteStopsDbo;
7 8
 import com.rthoni.stssaguenay.dbo.RoutesDbo;
8 9
 import com.rthoni.stssaguenay.dbo.SchedulesDbo;
@@ -25,7 +26,7 @@ public class SchedulesDataAccess extends LuDataAccess {
25 26
     {
26 27
         HashMap<String, String> map = new HashMap<>();
27 28
         map.put("count", Integer.toString(count));
28
-        map.put("date", JSONObject.quote(date.toString("y-M-d HH:mm:ss")));
29
+        map.put("date", JSONObject.quote(date.toString(LuDbo.DEFAULT_DATE_TIME_FORMAT)));
29 30
 
30 31
         JSONArray stops = new JSONArray();
31 32
         for (UserFavouriteStopsDbo dbo : favouriteStopDbos) {

+ 17
- 17
app/src/main/java/com/rthoni/stssaguenay/dbo/RoutesDbo.java View File

@@ -26,23 +26,23 @@ public class RoutesDbo extends LuDbo {
26 26
 
27 27
     protected String _fgColor;
28 28
 
29
-    @Override
30
-    public void fromJson(JSONObject json) throws JSONException {
31
-        _id = json.getString("id");
32
-        _name = json.getString("name");
33
-        _bgColor = json.getString("bgColor");
34
-        _fgColor = json.getString("fgColor");
35
-    }
36
-
37
-    @Override
38
-    public HashMap<String, Object> toArray() {
39
-        HashMap<String, Object> map = new HashMap<>();
40
-        map.put("id", _id);
41
-        map.put("name", _name);
42
-        map.put("bgColor", _bgColor);
43
-        map.put("fgColor", _fgColor);
44
-        return map;
45
-    }
29
+//    @Override
30
+//    public void fromJson(JSONObject json) throws JSONException {
31
+//        _id = json.getString("id");
32
+//        _name = json.getString("name");
33
+//        _bgColor = json.getString("bgColor");
34
+//        _fgColor = json.getString("fgColor");
35
+//    }
36
+//
37
+//    @Override
38
+//    public HashMap<String, Object> toArray() {
39
+//        HashMap<String, Object> map = new HashMap<>();
40
+//        map.put("id", _id);
41
+//        map.put("name", _name);
42
+//        map.put("bgColor", _bgColor);
43
+//        map.put("fgColor", _fgColor);
44
+//        return map;
45
+//    }
46 46
 
47 47
     public String getId() {
48 48
         return _id;

+ 15
- 15
app/src/main/java/com/rthoni/stssaguenay/dbo/SchedulesDbo.java View File

@@ -31,21 +31,21 @@ public class SchedulesDbo extends LuDbo {
31 31
 
32 32
     protected List<LocalDateTime> _schedules;
33 33
 
34
-    @Override
35
-    public void fromJson(JSONObject json) throws JSONException {
36
-        _stopId = json.getString("stopId");
37
-        _routeId = json.getString("routeId");
38
-        _schedules = new Vector<>();
39
-        JSONArray schedules = json.getJSONArray("schedules");
40
-        for (int i = 0; i < schedules.length(); ++i) {
41
-            _schedules.add(LocalDateTime.parse(schedules.getString(i), DateTimeFormat.forPattern("y-M-d H:m:s")));
42
-        }
43
-    }
44
-
45
-    @Override
46
-    public HashMap<String, Object> toArray() {
47
-        return null;
48
-    }
34
+//    @Override
35
+//    public void fromJson(JSONObject json) throws JSONException {
36
+//        _stopId = json.getString("stopId");
37
+//        _routeId = json.getString("routeId");
38
+//        _schedules = new Vector<>();
39
+//        JSONArray schedules = json.getJSONArray("schedules");
40
+//        for (int i = 0; i < schedules.length(); ++i) {
41
+//            _schedules.add(LocalDateTime.parse(schedules.getString(i), DateTimeFormat.forPattern("y-M-d H:m:s")));
42
+//        }
43
+//    }
44
+//
45
+//    @Override
46
+//    public HashMap<String, Object> toArray() {
47
+//        return null;
48
+//    }
49 49
 
50 50
     public String getStopId() {
51 51
         return _stopId;

+ 23
- 23
app/src/main/java/com/rthoni/stssaguenay/dbo/StopsDbo.java View File

@@ -22,29 +22,29 @@ public class StopsDbo extends LuDbo {
22 22
     {
23 23
     }
24 24
 
25
-    @Override
26
-    public void fromJson(JSONObject json) throws JSONException {
27
-        _name = json.getString("name");
28
-        _routes = new Vector<>();
29
-        JSONArray routes = json.getJSONArray("routes");
30
-        for (int i = 0; i < routes.length(); ++i) {
31
-            _routes.add(routes.getString(i));
32
-        }
33
-        _id = json.getString("id");
34
-        _posX = json.getDouble("posX");
35
-        _posY = json.getDouble("posY");
36
-    }
37
-
38
-    @Override
39
-    public HashMap<String, Object> toArray() {
40
-        HashMap<String, Object> map = new HashMap<>();
41
-        map.put("name", _name);
42
-        map.put("routes", _routes);
43
-        map.put("id", _id);
44
-        map.put("posX", _posX);
45
-        map.put("posY", _posY);
46
-        return map;
47
-    }
25
+//    @Override
26
+//    public void fromJson(JSONObject json) throws JSONException {
27
+//        _name = json.getString("name");
28
+//        _routes = new Vector<>();
29
+//        JSONArray routes = json.getJSONArray("routes");
30
+//        for (int i = 0; i < routes.length(); ++i) {
31
+//            _routes.add(routes.getString(i));
32
+//        }
33
+//        _id = json.getString("id");
34
+//        _posX = json.getDouble("posX");
35
+//        _posY = json.getDouble("posY");
36
+//    }
37
+//
38
+//    @Override
39
+//    public HashMap<String, Object> toArray() {
40
+//        HashMap<String, Object> map = new HashMap<>();
41
+//        map.put("name", _name);
42
+//        map.put("routes", _routes);
43
+//        map.put("id", _id);
44
+//        map.put("posX", _posX);
45
+//        map.put("posY", _posY);
46
+//        return map;
47
+//    }
48 48
 
49 49
     protected String _name;
50 50
 

+ 15
- 15
app/src/main/java/com/rthoni/stssaguenay/dbo/UserDbo.java View File

@@ -19,21 +19,21 @@ public class UserDbo extends LuDbo {
19 19
 
20 20
     protected String _email;
21 21
 
22
-    @Override
23
-    public void fromJson(JSONObject json) throws JSONException {
24
-        _id = json.getString("id");
25
-        _name = json.getString("name");
26
-        _email = json.getString("email");
27
-    }
28
-
29
-    @Override
30
-    public HashMap<String, Object> toArray() {
31
-        HashMap<String, Object> map = new HashMap<>();
32
-        map.put("id", _id);
33
-        map.put("name", _name);
34
-        map.put("email", _email);
35
-        return map;
36
-    }
22
+//    @Override
23
+//    public void fromJson(JSONObject json) throws JSONException {
24
+//        _id = json.getString("id");
25
+//        _name = json.getString("name");
26
+//        _email = json.getString("email");
27
+//    }
28
+//
29
+//    @Override
30
+//    public HashMap<String, Object> toArray() {
31
+//        HashMap<String, Object> map = new HashMap<>();
32
+//        map.put("id", _id);
33
+//        map.put("name", _name);
34
+//        map.put("email", _email);
35
+//        return map;
36
+//    }
37 37
 
38 38
     public String getId() {
39 39
         return _id;

+ 26
- 26
app/src/main/java/com/rthoni/stssaguenay/dbo/UserFavouriteStopsDbo.java View File

@@ -22,32 +22,32 @@ public class UserFavouriteStopsDbo extends LuDbo {
22 22
 
23 23
     protected String _name;
24 24
 
25
-    @Override
26
-    public void fromJson(JSONObject json) throws JSONException {
27
-        _stop = new StopsDbo();
28
-        _stop.fromJson(json.getJSONObject("stop"));
29
-        _routes = new Vector<>();
30
-        JSONArray routes = json.getJSONArray("routes");
31
-        for (int i = 0; i < routes.length(); ++i) {
32
-            RoutesDbo route = new RoutesDbo();
33
-            route.fromJson(routes.getJSONObject(i));
34
-            _routes.add(route);
35
-        }
36
-        _name = json.getString("name");
37
-    }
38
-
39
-    @Override
40
-    public HashMap<String, Object> toArray() {
41
-        HashMap<String, Object> map = new HashMap<>();
42
-        map.put("stop", _stop.toArray());
43
-        List<Object> routes = new Vector<>();
44
-        for (RoutesDbo route : _routes) {
45
-            routes.add(route.toArray());
46
-        }
47
-        map.put("routes", routes);
48
-        map.put("name", _name);
49
-        return map;
50
-    }
25
+//    @Override
26
+//    public void fromJson(JSONObject json) throws JSONException {
27
+//        _stop = new StopsDbo();
28
+//        _stop.fromJson(json.getJSONObject("stop"));
29
+//        _routes = new Vector<>();
30
+//        JSONArray routes = json.getJSONArray("routes");
31
+//        for (int i = 0; i < routes.length(); ++i) {
32
+//            RoutesDbo route = new RoutesDbo();
33
+//            route.fromJson(routes.getJSONObject(i));
34
+//            _routes.add(route);
35
+//        }
36
+//        _name = json.getString("name");
37
+//    }
38
+//
39
+//    @Override
40
+//    public HashMap<String, Object> toArray() {
41
+//        HashMap<String, Object> map = new HashMap<>();
42
+//        map.put("stop", _stop.toArray());
43
+//        List<Object> routes = new Vector<>();
44
+//        for (RoutesDbo route : _routes) {
45
+//            routes.add(route.toArray());
46
+//        }
47
+//        map.put("routes", routes);
48
+//        map.put("name", _name);
49
+//        return map;
50
+//    }
51 51
 
52 52
     public StopsDbo getStop() {
53 53
         return _stop;

+ 21
- 21
app/src/main/java/com/rthoni/stssaguenay/dbo/UsersSettingsDbo.java View File

@@ -17,27 +17,27 @@ import java.util.Vector;
17 17
 public class UsersSettingsDbo extends LuDbo {
18 18
     protected List<UserFavouriteStopsDbo> _favouriteStops;
19 19
 
20
-    @Override
21
-    public void fromJson(JSONObject json) throws JSONException {
22
-        _favouriteStops = new Vector<>();
23
-        JSONArray stops = json.getJSONArray("favouriteStops");
24
-        for (int i = 0; i < stops.length(); ++i) {
25
-            UserFavouriteStopsDbo stop = new UserFavouriteStopsDbo();
26
-            stop.fromJson(stops.getJSONObject(i));
27
-            _favouriteStops.add(stop);
28
-        }
29
-    }
30
-
31
-    @Override
32
-    public HashMap<String, Object> toArray() {
33
-        HashMap<String, Object> map = new HashMap<>();
34
-        List<HashMap<String, Object>> stops = new Vector<>();
35
-        for (UserFavouriteStopsDbo stop : _favouriteStops) {
36
-            stops.add(stop.toArray());
37
-        }
38
-        map.put("favouriteStops", stops);
39
-        return map;
40
-    }
20
+//    @Override
21
+//    public void fromJson(JSONObject json) throws JSONException {
22
+//        _favouriteStops = new Vector<>();
23
+//        JSONArray stops = json.getJSONArray("favouriteStops");
24
+//        for (int i = 0; i < stops.length(); ++i) {
25
+//            UserFavouriteStopsDbo stop = new UserFavouriteStopsDbo();
26
+//            stop.fromJson(stops.getJSONObject(i));
27
+//            _favouriteStops.add(stop);
28
+//        }
29
+//    }
30
+//
31
+//    @Override
32
+//    public HashMap<String, Object> toArray() {
33
+//        HashMap<String, Object> map = new HashMap<>();
34
+//        List<HashMap<String, Object>> stops = new Vector<>();
35
+//        for (UserFavouriteStopsDbo stop : _favouriteStops) {
36
+//            stops.add(stop.toArray());
37
+//        }
38
+//        map.put("favouriteStops", stops);
39
+//        return map;
40
+//    }
41 41
 
42 42
     public List<UserFavouriteStopsDbo> getFavouriteStops() {
43 43
         return _favouriteStops;

+ 1
- 1
app/src/main/java/com/rthoni/stssaguenay/ui/activities/MainActivity.java View File

@@ -150,7 +150,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
150 150
                                     UserDbo userDbo = new UserDbo();
151 151
                                     userDbo.fromJson(object);
152 152
                                     onUserLogged(userDbo);
153
-                                } catch (JSONException e) {
153
+                                } catch (Exception e) {
154 154
                                     e.printStackTrace();
155 155
                                 }
156 156
                             }

+ 1
- 0
build.gradle View File

@@ -15,6 +15,7 @@ buildscript {
15 15
         classpath 'com.android.tools.build:gradle:2.2.2'
16 16
         classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
17 17
         classpath 'com.google.gms:google-services:3.0.0'
18
+        classpath 'de.mobilej.unmock:UnMockPlugin:0.5.0'
18 19
 
19 20
         // NOTE: Do not place your application dependencies here; they belong
20 21
         // in the individual module build.gradle files

+ 9
- 1
luticateutils/build.gradle View File

@@ -1,4 +1,5 @@
1 1
 apply plugin: 'com.android.library'
2
+apply plugin: 'de.mobilej.unmock'
2 3
 
3 4
 android {
4 5
     compileSdkVersion 22
@@ -18,9 +19,16 @@ android {
18 19
     }
19 20
 }
20 21
 
22
+unMock {
23
+    // URI to download the android-all.jar from. e.g. https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/
24
+    downloadFrom 'https://oss.sonatype.org/content/groups/public/org/robolectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.jar'
25
+
26
+    keepStartingWith "org.json."
27
+}
28
+
21 29
 dependencies {
22 30
     compile fileTree(dir: 'libs', include: ['*.jar'])
23 31
     testCompile 'junit:junit:4.12'
24
-    testCompile 'org.json:json:20160810'
25 32
     compile 'com.android.volley:volley:1.0.0'
33
+    compile 'net.danlew:android.joda:2.9.4.2'
26 34
 }

+ 43
- 15
luticateutils/src/main/java/com/luticate/utils/dbo/LuDbo.java View File

@@ -4,7 +4,12 @@ import com.luticate.utils.dbo.JSONContainer.LuAbstractJsonContainer;
4 4
 import com.luticate.utils.dbo.JSONContainer.LuJSONArrayContainer;
5 5
 import com.luticate.utils.dbo.JSONContainer.LuJSONObjectContainer;
6 6
 
7
+import org.joda.time.DateTime;
8
+import org.joda.time.LocalDate;
9
+import org.joda.time.LocalDateTime;
10
+import org.joda.time.format.DateTimeFormat;
7 11
 import org.json.JSONArray;
12
+import org.json.JSONException;
8 13
 import org.json.JSONObject;
9 14
 
10 15
 import java.lang.reflect.Array;
@@ -21,11 +26,11 @@ import java.util.Vector;
21 26
  */
22 27
 public abstract class LuDbo {
23 28
 
24
-    public void fromString(String data) throws Exception
25
-    {
26
-        JSONObject json = new JSONObject(data);
27
-        fromJson(json);
28
-    }
29
+    public static String DEFAULT_DATE_FORMAT = "yy-MM-dd";
30
+
31
+    public static String DEFAULT_TIME_FORMAT = "HH:mm:ss";
32
+
33
+    public static String DEFAULT_DATE_TIME_FORMAT = DEFAULT_DATE_FORMAT + " " + DEFAULT_TIME_FORMAT;
29 34
 
30 35
     public String getFieldFromJson(String jsonName)
31 36
     {
@@ -75,6 +80,12 @@ public abstract class LuDbo {
75 80
         if (clazz == String.class) {
76 81
             return json.getString(key);
77 82
         }
83
+        if (clazz == LocalDateTime.class) {
84
+            return LocalDateTime.parse(json.getString(key), DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
85
+        }
86
+        if (clazz == DateTime.class) {
87
+            return DateTime.parse(json.getString(key), DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
88
+        }
78 89
         if (LuDbo.class.isAssignableFrom(clazz)) {
79 90
             LuDbo dbo = (LuDbo) getInstance(clazz);
80 91
             dbo.fromJson(json.getJSONObject(key));
@@ -97,38 +108,47 @@ public abstract class LuDbo {
97 108
                 || clazz == String.class) {
98 109
             return obj;
99 110
         }
111
+        if (clazz == LocalDateTime.class) {
112
+            return ((LocalDateTime)obj).toString(DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
113
+        }
114
+        if (clazz == DateTime.class) {
115
+            return ((DateTime)obj).toString(DateTimeFormat.forPattern(DEFAULT_DATE_TIME_FORMAT));
116
+        }
100 117
         if (LuDbo.class.isAssignableFrom(clazz)) {
101
-            return ((LuDbo)obj).toArray();
118
+            return ((LuDbo)obj).toJson();
102 119
         }
103 120
         if (List.class.isAssignableFrom(clazz)) {
104 121
             List objList = (List) obj;
105
-            List list = new Vector();
122
+            JSONArray list = new JSONArray();
106 123
 
107 124
             for (Object item : objList) {
108
-                list.add(getJsonFromObject(getClazz(item), item));
125
+                list.put(getJsonFromObject(getClazz(item), item));
109 126
             }
110 127
 
111 128
             return list;
112 129
         }
113 130
         if (AbstractMap.class.isAssignableFrom(clazz)) {
114 131
             HashMap objMap = (HashMap) obj;
115
-            HashMap map = new HashMap();
132
+            JSONObject map = new JSONObject();
116 133
 
117 134
             for (Object k : objMap.keySet()) {
118 135
                 if (k.getClass() == String.class) {
119 136
                     Object item = objMap.get(k);
120
-                    map.put(k, getJsonFromObject(getClazz(item), item));
137
+                    try {
138
+                        map.put((String) k, getJsonFromObject(getClazz(item), item));
139
+                    } catch (JSONException ignored) {
140
+                    }
121 141
                 }
122 142
             }
123 143
 
124 144
             return map;
125 145
         }
126 146
         if (clazz.isArray()) {
127
-            List list = new Vector();
147
+            JSONArray list = new JSONArray();
128 148
 
129 149
             for (int i = 0; i < Array.getLength(obj); ++i) {
130 150
                 Object item = Array.get(obj, i);
131
-                list.add(getJsonFromObject(item == null ? null : item.getClass(), item));
151
+                list.put(getJsonFromObject(item == null ? null : item.getClass(), item));
132 152
             }
133 153
 
134 154
             return list;
@@ -151,6 +171,12 @@ public abstract class LuDbo {
151 171
         return obj == null ? null : obj.getClass();
152 172
     }
153 173
 
174
+    public void fromString(String data) throws Exception
175
+    {
176
+        JSONObject json = new JSONObject(data);
177
+        fromJson(json);
178
+    }
179
+
154 180
     public void fromJson(JSONObject json) throws Exception
155 181
     {
156 182
         for (Field field : getClass().getDeclaredFields()) {
@@ -214,8 +240,7 @@ public abstract class LuDbo {
214 240
             Object obj = null;
215 241
             try {
216 242
                 obj = field.get(this);
217
-            } catch (IllegalAccessException e) {
218
-                e.printStackTrace();
243
+            } catch (IllegalAccessException ignored) {
219 244
             }
220 245
             field.setAccessible(false);
221 246
             map.put(key, getJsonFromObject(clazz, obj));
@@ -226,7 +251,9 @@ public abstract class LuDbo {
226 251
 
227 252
     public JSONObject toJson()
228 253
     {
229
-        return new JSONObject(toArray());
254
+        HashMap<String, Object> array = toArray();
255
+        JSONObject json = new JSONObject(array);
256
+        return json;
230 257
     }
231 258
 
232 259
     @Override
@@ -234,4 +261,5 @@ public abstract class LuDbo {
234 261
     {
235 262
         return toJson().toString();
236 263
     }
264
+
237 265
 }

+ 26
- 1
luticateutils/src/test/java/com/luticate/utils/TestDbo.java View File

@@ -45,6 +45,9 @@ public class TestDbo extends LuDbo implements Serializable {
45 45
     protected HashMap<String, Integer> _hashMap;
46 46
     protected AbstractMap<String, Test2Dbo> _hashMap2;
47 47
 
48
+    protected String _aNullString;
49
+    protected Class _object = TestDbo.class;
50
+
48 51
     public byte getByte() {
49 52
         return _byte;
50 53
     }
@@ -245,6 +248,22 @@ public class TestDbo extends LuDbo implements Serializable {
245 248
         _hashMap2 = hashMap2;
246 249
     }
247 250
 
251
+    public String getaNullString() {
252
+        return _aNullString;
253
+    }
254
+
255
+    public void setaNullString(String aNullString) {
256
+        _aNullString = aNullString;
257
+    }
258
+
259
+    public Class getObject() {
260
+        return _object;
261
+    }
262
+
263
+    public void setObject(Class object) {
264
+        _object = object;
265
+    }
266
+
248 267
     @Override
249 268
     public boolean equals(Object o) {
250 269
         if (this == o) return true;
@@ -291,7 +310,11 @@ public class TestDbo extends LuDbo implements Serializable {
291 310
         if (!Arrays.equals(_dbos, testDbo._dbos)) return false;
292 311
         if (_hashMap != null ? !_hashMap.equals(testDbo._hashMap) : testDbo._hashMap != null)
293 312
             return false;
294
-        return _hashMap2 != null ? _hashMap2.equals(testDbo._hashMap2) : testDbo._hashMap2 == null;
313
+        if (_hashMap2 != null ? !_hashMap2.equals(testDbo._hashMap2) : testDbo._hashMap2 != null)
314
+            return false;
315
+        if (_aNullString != null ? !_aNullString.equals(testDbo._aNullString) : testDbo._aNullString != null)
316
+            return false;
317
+        return _object != null ? _object.equals(testDbo._object) : testDbo._object == null;
295 318
 
296 319
     }
297 320
 
@@ -325,6 +348,8 @@ public class TestDbo extends LuDbo implements Serializable {
325 348
         result = 31 * result + Arrays.hashCode(_dbos);
326 349
         result = 31 * result + (_hashMap != null ? _hashMap.hashCode() : 0);
327 350
         result = 31 * result + (_hashMap2 != null ? _hashMap2.hashCode() : 0);
351
+        result = 31 * result + (_aNullString != null ? _aNullString.hashCode() : 0);
352
+        result = 31 * result + (_object != null ? _object.hashCode() : 0);
328 353
         return result;
329 354
     }
330 355
 }

+ 9
- 3
luticateutils/src/test/java/com/luticate/utils/TestDboTest.java View File

@@ -71,7 +71,11 @@ public class TestDboTest {
71 71
             "\"aString\": \"42 24\"," +
72 72
             "\"aInt\": 4224" +
73 73
             "}" +
74
-            "}" +
74
+            "}," +
75
+
76
+            "\"aNullString\": null," +
77
+
78
+            "\"object\": {}" +
75 79
 
76 80
             "}";
77 81
 
@@ -138,6 +142,9 @@ public class TestDboTest {
138 142
         assertEquals("42 24", test.getHashMap2().get("an object").getaString());
139 143
         assertEquals(4224, test.getHashMap2().get("an object").getaInt());
140 144
 
145
+        assertNull(test.getaNullString());
146
+        assertNull(test.getObject());
147
+
141 148
         assertEquals(test, test);
142 149
     }
143 150
 
@@ -166,10 +173,9 @@ public class TestDboTest {
166 173
     {
167 174
         TestDbo test = new TestDbo();
168 175
         test.fromString(TEST_DBO_JSON);
169
-        JSONObject json = test.toJson();
170 176
 
171 177
         TestDbo test2 = new TestDbo();
172
-        test2.fromString(json.toString());
178
+        test2.fromString(test.toString());
173 179
 
174 180
         testTestDbo(test2);
175 181
     }

Loading…
Cancel
Save