com.github.dreamhead.moco.parser.deserializer.ReplayModifierContainerDeserializer 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.ReplayContainer;
import com.github.dreamhead.moco.parser.model.ReplayModifierContainer;
import com.github.dreamhead.moco.parser.model.ResponseSetting;
import java.io.IOException;
import static com.github.dreamhead.moco.util.Strings.strip;
public class ReplayModifierContainerDeserializer extends JsonDeserializer {
@Override
public final ReplayModifierContainer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
JsonToken currentToken = p.getCurrentToken();
if (currentToken == JsonToken.VALUE_STRING) {
return new ReplayModifierContainer(strip(p.getText()));
}
if (currentToken == JsonToken.START_OBJECT) {
p.nextToken();
ResponseSetting setting = p.readValueAs(ResponseSetting.class);
return new ReplayModifierContainer(setting);
}
return (ReplayModifierContainer) ctxt.handleUnexpectedToken(ReplayContainer.class, p);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy