001package org.gbif.api.jackson;
002
003import org.gbif.api.vocabulary.Extension;
004
005import java.io.IOException;
006
007import org.codehaus.jackson.JsonParser;
008import org.codehaus.jackson.JsonToken;
009import org.codehaus.jackson.map.DeserializationContext;
010import org.codehaus.jackson.map.JsonDeserializer;
011
012public class ExtensionDeserializer extends JsonDeserializer<Extension> {
013
014  @Override
015  public Extension deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
016    if (jp.getCurrentToken() == JsonToken.VALUE_STRING) {
017      return Extension.fromRowType(jp.getText());
018    }
019    throw ctxt.mappingException("Expected JSON String");
020  }
021}
022