com.github.dreamhead.moco.dumper.HttpProtocolVersionDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco.dumper;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.github.dreamhead.moco.HttpProtocolVersion;
import java.io.IOException;
import static com.github.dreamhead.moco.util.Strings.strip;
public class HttpProtocolVersionDeserializer extends JsonDeserializer {
@Override
public HttpProtocolVersion deserialize(final JsonParser jp, final DeserializationContext ctx) throws IOException {
try {
return HttpProtocolVersion.versionOf(strip(jp.getText()));
} catch (IllegalArgumentException e) {
return (HttpProtocolVersion) ctx.handleUnexpectedToken(HttpProtocolVersion.class, jp);
}
}
}