All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.geotab.model.serialization.FaultStateDeserializer 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.FaultState;
import java.io.IOException;

/**
 * Custom {@link FaultState} deserializer, which returns {@link FaultState#NONE} as default if the
 * json value is not recognized.
 */
public class FaultStateDeserializer extends JsonDeserializer {

  @Override
  public FaultState deserialize(JsonParser jsonParser,
      DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    return FaultState.findOrDefault(jsonParser.getValueAsString());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy