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

com.github.dreamhead.moco.dumper.HttpProtocolVersionDeserializer Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
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 final 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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy