fromJson実装 WIP

This commit is contained in:
r-ca 2024-01-14 12:50:56 +09:00
parent e07cbda769
commit e9b7ad4d92
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -44,12 +44,22 @@ public class JsonUtils {
throw new IllegalArgumentException("Unknown object type"); throw new IllegalArgumentException("Unknown object type");
} }
public static Object fromJson(String json, ActionType actionType) {
public static <T> T fromJson(String json, ActionType actionType, Class<T> clazz) { ObjectMapper mapper = new ObjectMapper();
return null; 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
} }