com.geotab.model.serialization.DbUnavailableStateDeserializer 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.DbUnavailableState;
import java.io.IOException;
/**
* Custom {@link DbUnavailableState} deserializer, which returns {@link DbUnavailableState#NONE} as
* default if the json value is not recognized.
*/
public class DbUnavailableStateDeserializer extends JsonDeserializer {
@Override
public DbUnavailableState deserialize(JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
return DbUnavailableState.findOrDefault(jsonParser.getValueAsString());
}
}