de.eldoria.eldoutilities.config.parsing.deserializer.LevelDeserializer Maven / Gradle / Ivy
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Copyright (C) EldoriaRPG Team and Contributor
*/
package de.eldoria.eldoutilities.config.parsing.deserializer;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;
import java.util.logging.Level;
public class LevelDeserializer extends JsonDeserializer {
private static Level parseLevel(String level) {
return switch (level.toUpperCase()) {
case "OFF" -> Level.OFF;
case "SEVERE" -> Level.SEVERE;
case "WARNING" -> Level.WARNING;
case "DEBUG", "TRUE" -> Level.CONFIG;
case "FINE" -> Level.FINE;
case "FINER" -> Level.FINER;
case "FINEST" -> Level.FINEST;
case "ALL" -> Level.ALL;
default -> Level.INFO;
};
}
@Override
public Level deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return parseLevel(p.getText());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy