diff options
author | desperateCoder <echotodevnull@gmail.com> | 2020-11-22 20:43:29 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-11-22 21:02:36 +0300 |
commit | 0ec28927d9a3560782fad60db1fdee364dc80bcf (patch) | |
tree | 27395b8628690e93d3285a8ad923e0e8b85ac4be /app/src/main/java/it/niedermann/nextcloud/deck/api | |
parent | 727a31ef4a9eb30333dc3694539342eb7bf624ed (diff) |
#359 more efficient etag-null handling
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/api')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java b/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java index 22d84850e..e759f27d4 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java @@ -284,7 +284,7 @@ public class JsonToEntityParser { makeTraceableIfFails(() -> { board.setTitle(getNullAsEmptyString(e.get("title"))); board.setColor(getNullAsEmptyString(e.get("color"))); - board.setEtag(getNullAsEmptyString(e.get("ETag"))); + board.setEtag(getNullAsNull(e.get("ETag"))); board.setArchived(e.get("archived").getAsBoolean()); board.setLastModified(getTimestampFromLong(e.get("lastModified"))); @@ -397,7 +397,7 @@ public class JsonToEntityParser { card.setDescription(getNullAsEmptyString(e.get("description"))); card.setStackId(e.get("stackId").getAsLong()); card.setType(getNullAsEmptyString(e.get("type"))); - card.setEtag(getNullAsEmptyString(e.get("ETag"))); + card.setEtag(getNullAsNull(e.get("ETag"))); card.setLastModified(getTimestampFromLong(e.get("lastModified"))); card.setCreatedAt(getTimestampFromLong(e.get("createdAt"))); card.setDeletedAt(getTimestampFromLong(e.get("deletedAt"))); @@ -458,7 +458,7 @@ public class JsonToEntityParser { a.setId(e.get("id").getAsLong()); a.setCardId(e.get("cardId").getAsLong()); a.setType(e.get("type").getAsString()); - a.setEtag(getNullAsEmptyString(e.get("ETag"))); + a.setEtag(getNullAsNull(e.get("ETag"))); a.setData(e.get("data").getAsString()); a.setLastModified(getTimestampFromLong(e.get("lastModified"))); a.setCreatedAt(getTimestampFromLong(e.get("createdAt"))); @@ -583,7 +583,7 @@ public class JsonToEntityParser { stack.setTitle(getNullAsEmptyString(e.get("title"))); stack.setBoardId(e.get("boardId").getAsLong()); stack.setId(e.get("id").getAsLong()); - stack.setEtag(getNullAsEmptyString(e.get("ETag"))); + stack.setEtag(getNullAsNull(e.get("ETag"))); stack.setLastModified(getTimestampFromLong(e.get("lastModified"))); stack.setDeletedAt(getTimestampFromLong(e.get("deletedAt"))); if (e.has("order") && !e.get("order").isJsonNull()) { @@ -621,7 +621,7 @@ public class JsonToEntityParser { activity.setType(ActivityType.findByPath(getNullAsEmptyString(activityObject.get("icon"))).getId()); activity.setSubject(getNullAsEmptyString(activityObject.get("subject"))); activity.setCardId(activityObject.get("object_id").getAsLong()); - activity.setEtag(getNullAsEmptyString(e.get("ETag"))); + activity.setEtag(getNullAsNull(e.get("ETag"))); activity.setLastModified(getTimestampFromString(activityObject.get("datetime"))); activityList.add(activity); @@ -640,7 +640,7 @@ public class JsonToEntityParser { //todo: last modified! // label.setLastModified(get); label.setTitle(getNullAsEmptyString(e.get("title"))); - label.setEtag(getNullAsEmptyString(e.get("ETag"))); + label.setEtag(getNullAsNull(e.get("ETag"))); label.setColor(getColorAsInt(e, "color")); }, e); return label; @@ -650,6 +650,10 @@ public class JsonToEntityParser { return jsonElement == null || jsonElement.isJsonNull() ? "" : jsonElement.getAsString(); } + private static String getNullAsNull(JsonElement jsonElement) { + return jsonElement == null || jsonElement.isJsonNull() ? null : jsonElement.getAsString(); + } + private static Instant getTimestampFromString(JsonElement jsonElement) { if (jsonElement.isJsonNull()) { return null; |