com.geotab.model.serialization.FaultLampStateDeserializer Maven / Gradle / Ivy
/*
*
* 2020 Copyright (C) Geotab Inc. All rights reserved.
*/
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.FaultLampState;
import java.io.IOException;
/**
* Custom {@link FaultLampState} deserializer, which returns {@link FaultLampState#NONE} as default
* if the json value is not recognized.
*/
public class FaultLampStateDeserializer extends JsonDeserializer {
@Override
public FaultLampState deserialize(JsonParser jsonParser,
DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
return FaultLampState.findOrDefault(jsonParser.getValueAsString());
}
}