
org.opentripplanner.api.model.AgencyAndIdDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.api.model;
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 org.onebusaway.gtfs.model.AgencyAndId;
import java.io.IOException;
public class AgencyAndIdDeserializer extends JsonDeserializer {
public static final String SEPARATOR = ":";
@Override
public AgencyAndId deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
String string = jp.getValueAsString();
String[] parts = string.split(SEPARATOR, 2);
return new AgencyAndId(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 AgencyAndId.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy