com.github.dreamhead.moco.parser.deserializer.TextContainerDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-runner Show documentation
Show all versions of moco-runner Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco.parser.deserializer;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.github.dreamhead.moco.parser.model.TextContainer;
import java.io.IOException;
public final class TextContainerDeserializer extends JsonDeserializer {
private TextContainerDeserializerHelper helper = new TextContainerDeserializerHelper();
@Override
public TextContainer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException {
JsonToken currentToken = jp.getCurrentToken();
if (currentToken == JsonToken.VALUE_STRING) {
return helper.text(jp);
}
if (currentToken == JsonToken.START_OBJECT) {
jp.nextToken();
return helper.textContainer(jp, ctxt);
}
return (TextContainer) ctxt.handleUnexpectedToken(TextContainer.class, jp);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy