use of com.github.dreamhead.moco.parser.model.LatencyContainer in project moco by dreamhead.
the class LatencyContainerDeserializer method deserialize.
@Override
public LatencyContainer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException {
JsonToken currentToken = jp.getCurrentToken();
if (currentToken == JsonToken.VALUE_NUMBER_INT) {
return LatencyContainer.latency(jp.getLongValue());
}
if (currentToken == JsonToken.START_OBJECT) {
jp.nextToken();
InternalLatencyContainer container = get(jp.readValuesAs(InternalLatencyContainer.class), 0);
return LatencyContainer.latencyWithUnit(container.duration, TimeUnit.valueOf(container.unit.toUpperCase() + 'S'));
}
return (LatencyContainer) ctxt.handleUnexpectedToken(LatencyContainer.class, jp);
}
Aggregations