use of com.fasterxml.jackson.core.ObjectCodec in project druid by druid-io.
the class AggregationTestHelper method readQueryResultArrayFromString.
private List readQueryResultArrayFromString(String str) throws Exception {
List result = new ArrayList();
JsonParser jp = mapper.getFactory().createParser(str);
if (jp.nextToken() != JsonToken.START_ARRAY) {
throw new IAE("not an array [%s]", str);
}
ObjectCodec objectCodec = jp.getCodec();
while (jp.nextToken() != JsonToken.END_ARRAY) {
result.add(objectCodec.readValue(jp, toolChest.getResultTypeReference()));
}
return result;
}
use of com.fasterxml.jackson.core.ObjectCodec in project ratpack by ratpack.
the class ServerConfigDataDeserializer method deserialize.
@Override
public ServerConfigData deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
ObjectCodec codec = jp.getCodec();
ObjectNode serverNode = jp.readValueAsTree();
ServerConfigData data = new ServerConfigData(baseDirSupplier.get(), address, port, development, publicAddress);
if (serverNode.hasNonNull("port")) {
data.setPort(parsePort(serverNode.get("port")));
}
if (serverNode.hasNonNull("address")) {
data.setAddress(toValue(codec, serverNode.get("address"), InetAddress.class));
}
if (serverNode.hasNonNull("development")) {
data.setDevelopment(serverNode.get("development").asBoolean(false));
}
if (serverNode.hasNonNull("threads")) {
data.setThreads(serverNode.get("threads").asInt(ServerConfig.DEFAULT_THREADS));
}
if (serverNode.hasNonNull("publicAddress")) {
data.setPublicAddress(toValue(codec, serverNode.get("publicAddress"), URI.class));
}
if (serverNode.hasNonNull("maxContentLength")) {
data.setMaxContentLength(serverNode.get("maxContentLength").asInt(ServerConfig.DEFAULT_MAX_CONTENT_LENGTH));
}
if (serverNode.hasNonNull("maxChunkSize")) {
data.setMaxChunkSize(serverNode.get("maxChunkSize").asInt(ServerConfig.DEFAULT_MAX_CHUNK_SIZE));
}
if (serverNode.hasNonNull("maxInitialLineLength")) {
data.setMaxInitialLineLength(serverNode.get("maxInitialLineLength").asInt(ServerConfig.DEFAULT_MAX_INITIAL_LINE_LENGTH));
}
if (serverNode.hasNonNull("maxHeaderSize")) {
data.setMaxHeaderSize(serverNode.get("maxHeaderSize").asInt(ServerConfig.DEFAULT_MAX_HEADER_SIZE));
}
if (serverNode.hasNonNull("ssl")) {
data.setSslContext(toValue(codec, serverNode.get("ssl"), SSLContext.class));
}
if (serverNode.hasNonNull("requireClientSslAuth")) {
data.setRequireClientSslAuth(serverNode.get("requireClientSslAuth").asBoolean(false));
}
if (serverNode.hasNonNull("baseDir")) {
throw new IllegalStateException("baseDir value cannot be set via config, it must be set directly via ServerConfigBuilder.baseDir()");
}
if (serverNode.hasNonNull("connectTimeoutMillis")) {
parseOptionalIntValue("connectTimeoutMillis", serverNode.get("connectTimeoutMillis")).ifPresent(data::setConnectTimeoutMillis);
}
if (serverNode.hasNonNull("maxMessagesPerRead")) {
parseOptionalIntValue("maxMessagesPerRead", serverNode.get("maxMessagesPerRead")).ifPresent(data::setMaxMessagesPerRead);
}
if (serverNode.hasNonNull("receiveBufferSize")) {
parseOptionalIntValue("receiveBufferSize", serverNode.get("receiveBufferSize")).ifPresent(data::setReceiveBufferSize);
}
if (serverNode.hasNonNull("writeSpinCount")) {
parseOptionalIntValue("writeSpinCount", serverNode.get("writeSpinCount")).ifPresent(data::setWriteSpinCount);
}
return data;
}
use of com.fasterxml.jackson.core.ObjectCodec in project Rosetta by HubSpot.
the class RosettaModule method setupModule.
@Override
public void setupModule(SetupContext context) {
context.addBeanSerializerModifier(new StoredAsJsonBeanSerializerModifier());
ObjectCodec codec = context.getOwner();
if (codec instanceof ObjectMapper) {
ObjectMapper mapper = (ObjectMapper) codec;
context.insertAnnotationIntrospector(new RosettaAnnotationIntrospector(mapper));
mapper.setSerializerProvider(new DefaultSerializerProvider.Impl());
mapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
}
use of com.fasterxml.jackson.core.ObjectCodec in project shifu by ShifuML.
the class RunModeDeserializer method deserialize.
@Override
public RunMode deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);
for (RunMode value : RunMode.values()) {
if (value.name().equalsIgnoreCase(node.textValue())) {
return value;
}
}
return null;
}
use of com.fasterxml.jackson.core.ObjectCodec in project shifu by ShifuML.
the class SouceTypeDeserializer method deserialize.
@Override
public SourceType deserialize(JsonParser jp, DeserializationContext context) throws IOException {
ObjectCodec oc = jp.getCodec();
JsonNode node = oc.readTree(jp);
for (SourceType value : SourceType.values()) {
if (value.name().equalsIgnoreCase(node.textValue())) {
return value;
}
}
return null;
}
Aggregations