
org.opentripplanner.ext.restapi.serialization.FeedScopedIdDeserializer Maven / Gradle / Ivy
The newest version!
package org.opentripplanner.ext.restapi.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 java.io.IOException;
import org.opentripplanner.transit.model.framework.FeedScopedId;
public class FeedScopedIdDeserializer extends JsonDeserializer {
public static final String SEPARATOR = ":";
@Override
public FeedScopedId deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
String string = jp.getValueAsString();
String[] parts = string.split(SEPARATOR, 2);
return new FeedScopedId(parts[0], parts[1]);
}
// Gets around type erasure, allowing
// module.addSerializer(new ThingSerializer()) to correctly associate
// this serializer with the proper type.
@Override
public Class handledType() {
return FeedScopedId.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy