Commit 7d24e825 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Fixes checkstyle warnings

parent 457a162d
......@@ -12,7 +12,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.EnumSet;
import java.util.Set;
import todolist.core.TodoModel;
import todolist.json.internal.TodoModule;
......@@ -22,6 +21,9 @@ import todolist.json.internal.TodoModule;
*/
public class TodoPersistence {
/**
* Used to indicate what parts of a TodoModel to serialize.
*/
public enum TodoModelParts {
SETTINGS, LISTS, LIST_CONTENTS
}
......
......@@ -4,9 +4,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Set;
import todolist.core.AbstractTodoList;
import todolist.core.TodoModel;
import todolist.json.TodoPersistence.TodoModelParts;
......
package todolist.json.internal;
import java.util.EnumSet;
import java.util.Set;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.util.EnumSet;
import java.util.Set;
import todolist.core.AbstractTodoList;
import todolist.core.TodoItem;
import todolist.core.TodoModel;
......
......@@ -23,12 +23,12 @@ class TodoSettingsDeserializer extends JsonDeserializer<TodoSettings> {
TodoSettings deserialize(JsonNode jsonNode) {
if (jsonNode instanceof ObjectNode) {
ObjectNode objectNode = (ObjectNode) jsonNode;
TodoSettings settings = new TodoSettings();
JsonNode todoItemsSortOrderNode = objectNode.get(TodoSettings.TODO_ITEM_SORT_ORDER_SETTING);
var objectNode = (ObjectNode) jsonNode;
var settings = new TodoSettings();
var todoItemsSortOrderNode = objectNode.get(TodoSettings.TODO_ITEM_SORT_ORDER_SETTING);
if (todoItemsSortOrderNode instanceof TextNode) {
try {
TodoItemsSortOrder sortOrder = TodoItemsSortOrder.valueOf(todoItemsSortOrderNode.asText());
var sortOrder = TodoItemsSortOrder.valueOf(todoItemsSortOrderNode.asText());
settings.setTodoItemsSortOrder(sortOrder);
} catch (IllegalArgumentException iae) {
// ignore unknown sort order constant
......
......@@ -17,7 +17,8 @@ class TodoSettingsSerializer extends JsonSerializer<TodoSettings> {
SerializerProvider serializerProvider)
throws IOException {
jsonGen.writeStartObject();
jsonGen.writeStringField(TodoSettings.TODO_ITEM_SORT_ORDER_SETTING, settings.getTodoItemsSortOrder().name());
var sortOrderName = settings.getTodoItemsSortOrder().name();
jsonGen.writeStringField(TodoSettings.TODO_ITEM_SORT_ORDER_SETTING, sortOrderName);
jsonGen.writeEndObject();
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment