From e9b7ad4d9243427a1fb08b10975e8f5706532a7b Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 14 Jan 2024 12:50:56 +0900 Subject: [PATCH] =?UTF-8?q?fromJson=E5=AE=9F=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/internal/JsonUtils.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/internal/JsonUtils.java b/vcs/src/main/java/one/nem/lacerta/vcs/internal/JsonUtils.java index db9ac496..8925e51d 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/internal/JsonUtils.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/internal/JsonUtils.java @@ -44,12 +44,22 @@ public class JsonUtils { throw new IllegalArgumentException("Unknown object type"); } - - public static T fromJson(String json, ActionType actionType, Class clazz) { - return null; + public static Object fromJson(String json, ActionType actionType) { + ObjectMapper mapper = new ObjectMapper(); + try { + switch (actionType) { + case INSERT_PAGE: + return mapper.readValue(json, InsertPage.class); + case UPDATE_PAGE: + return mapper.readValue(json, UpdatePage.class); + case DELETE_PAGE: + return mapper.readValue(json, DeletePage.class); + default: + throw new IllegalArgumentException("Unknown action type"); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } - // Internal methods - - }