use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project streamline by hortonworks.
the class ConfigFileReader method readConfigFromYamlType.
private Map<String, String> readConfigFromYamlType(InputStream configFileStream) throws IOException {
ObjectReader reader = new YAMLMapper().reader();
Map<String, Object> confMap = reader.forType(new TypeReference<Map<String, Object>>() {
}).readValue(configFileStream);
return confMap.entrySet().stream().collect(toMap(Map.Entry::getKey, e -> convertValueAsString(e.getValue())));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project streamline by hortonworks.
the class ConfigFileReader method readConfigFromHadoopXmlType.
private Map<String, String> readConfigFromHadoopXmlType(InputStream configFileStream) throws IOException {
ObjectReader reader = new XmlMapper().reader();
HadoopXml hadoopXml = reader.forType(HadoopXml.class).readValue(configFileStream);
Map<String, String> configMap = new HashMap<>();
for (HadoopXml.HadoopXmlProperty property : hadoopXml.getProperties()) {
configMap.put(property.getName(), property.getValue());
}
return configMap;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project crnk-framework by crnk-project.
the class ResourceUpsert method setAttribute.
private void setAttribute(ResourceInformation resourceInformation, Object instance, String attributeName, JsonNode valueNode) {
ResourceField field = resourceInformation.findAttributeFieldByName(attributeName);
if (canModifyField(resourceInformation, attributeName, field)) {
try {
if (field != null) {
Type valueType = field.getGenericType();
Object value;
if (valueNode != null) {
JavaType jacksonValueType = objectMapper.getTypeFactory().constructType(valueType);
ObjectReader reader = objectMapper.reader().forType(jacksonValueType);
value = reader.readValue(valueNode);
} else {
value = null;
}
for (ResourceModificationFilter filter : modificationFilters) {
value = filter.modifyAttribute(instance, field, attributeName, value);
}
field.getAccessor().setValue(instance, value);
} else if (resourceInformation.getAnyFieldAccessor() != null) {
AnyResourceFieldAccessor anyFieldAccessor = resourceInformation.getAnyFieldAccessor();
Object value = objectMapper.reader().forType(Object.class).readValue(valueNode);
for (ResourceModificationFilter filter : modificationFilters) {
value = filter.modifyAttribute(instance, field, attributeName, value);
}
anyFieldAccessor.setValue(instance, attributeName, value);
}
} catch (IOException e) {
throw new ResourceException(String.format("Exception while setting %s.%s=%s due to %s", instance, attributeName, valueNode, e.getMessage()), e);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project crnk-framework by crnk-project.
the class ClientResourceUpsert method setMeta.
protected void setMeta(Resource dataBody, Object instance, ResourceInformation resourceInformation) {
ResourceField metaField = resourceInformation.getMetaField();
if (dataBody.getMeta() != null && metaField != null) {
JsonNode metaNode = dataBody.getMeta();
Class<?> metaClass = metaField.getType();
ObjectReader metaMapper = objectMapper.readerFor(metaClass);
try {
Object meta = metaMapper.readValue(metaNode);
metaField.getAccessor().setValue(instance, meta);
} catch (IOException e) {
throw new ResponseBodyException("failed to parse links information", e);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader in project autorest-clientruntime-for-java by Azure.
the class JacksonConverterFactory method responseBodyConverter.
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
JavaType javaType = mapper.getTypeFactory().constructType(type);
ObjectReader reader = mapper.reader(javaType);
return new JacksonResponseBodyConverter<>(reader);
}
Aggregations