com.geotab.model.serialization.HosRuleSetDeserializer Maven / Gradle / Ivy
package com.geotab.model.serialization;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.geotab.model.enumeration.HosRuleSet;
import java.io.IOException;
/**
* Custom {@link HosRuleSet} deserializer, which returns {@link HosRuleSet#NONE} as default if the
* json value is not recognized.
*/
public class HosRuleSetDeserializer extends JsonDeserializer {
@Override
public HosRuleSet deserialize(JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
return HosRuleSet.findOrDefault(jsonParser.getValueAsString());
}
}