use of com.fasterxml.jackson.databind.BeanDescription in project incubator-servicecomb-java-chassis by apache.
the class ConfigObjectFactory method createProperties.
public List<ConfigObjectProperty> createProperties(Object instance, String prefix, Map<String, Object> parameters) {
List<ConfigObjectProperty> properties = new ArrayList<>();
JavaType javaType = TypeFactory.defaultInstance().constructType(instance.getClass());
BeanDescription beanDescription = JsonUtils.OBJ_MAPPER.getSerializationConfig().introspect(javaType);
for (BeanPropertyDefinition propertyDefinition : beanDescription.findProperties()) {
if (propertyDefinition.getField() == null) {
continue;
}
if (propertyDefinition.getSetter() == null && !propertyDefinition.getField().isPublic()) {
continue;
}
Setter<Object, Object> setter = createObjectSetter(propertyDefinition);
PriorityProperty<?> priorityProperty = createPriorityProperty(propertyDefinition.getField().getAnnotated(), prefix, parameters);
setter.set(instance, priorityProperty.getValue());
properties.add(new ConfigObjectProperty(setter, priorityProperty));
}
return properties;
}
use of com.fasterxml.jackson.databind.BeanDescription in project incubator-servicecomb-java-chassis by apache.
the class JacksonPropertyNodeNameProvider method getJavaBeanPropertyName.
private String getJavaBeanPropertyName(JavaBeanProperty property) {
ObjectMapper objectMapper = DatabindCodec.mapper();
JavaType type = objectMapper.constructType(property.getDeclaringClass());
BeanDescription desc = objectMapper.getSerializationConfig().introspect(type);
return desc.findProperties().stream().filter(prop -> prop.getInternalName().equals(property.getName())).map(BeanPropertyDefinition::getName).findFirst().orElse(property.getName());
}
Aggregations