Search in sources :

Example 1 with Property

use of org.hibernate.validator.spi.nodenameprovider.Property in project java-chassis by ServiceComb.

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());
}
Also used : Property(org.hibernate.validator.spi.nodenameprovider.Property) DatabindCodec(io.vertx.core.json.jackson.DatabindCodec) PropertyNodeNameProvider(org.hibernate.validator.spi.nodenameprovider.PropertyNodeNameProvider) JavaBeanProperty(org.hibernate.validator.spi.nodenameprovider.JavaBeanProperty) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) JavaType(com.fasterxml.jackson.databind.JavaType) BeanPropertyDefinition(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition) JavaType(com.fasterxml.jackson.databind.JavaType) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) BeanPropertyDefinition(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with Property

use of org.hibernate.validator.spi.nodenameprovider.Property 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());
}
Also used : Property(org.hibernate.validator.spi.nodenameprovider.Property) DatabindCodec(io.vertx.core.json.jackson.DatabindCodec) PropertyNodeNameProvider(org.hibernate.validator.spi.nodenameprovider.PropertyNodeNameProvider) JavaBeanProperty(org.hibernate.validator.spi.nodenameprovider.JavaBeanProperty) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) JavaType(com.fasterxml.jackson.databind.JavaType) BeanPropertyDefinition(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition) JavaType(com.fasterxml.jackson.databind.JavaType) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) BeanPropertyDefinition(com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

BeanDescription (com.fasterxml.jackson.databind.BeanDescription)2 JavaType (com.fasterxml.jackson.databind.JavaType)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 BeanPropertyDefinition (com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition)2 DatabindCodec (io.vertx.core.json.jackson.DatabindCodec)2 JavaBeanProperty (org.hibernate.validator.spi.nodenameprovider.JavaBeanProperty)2 Property (org.hibernate.validator.spi.nodenameprovider.Property)2 PropertyNodeNameProvider (org.hibernate.validator.spi.nodenameprovider.PropertyNodeNameProvider)2