Example usage for com.fasterxml.jackson.databind.ser BeanSerializerBuilder getProperties

List of usage examples for com.fasterxml.jackson.databind.ser BeanSerializerBuilder getProperties

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.ser BeanSerializerBuilder getProperties.

Prototype

public List<BeanPropertyWriter> getProperties() 

Source Link

Usage

From source file:org.jddd.jackson.SimpleValueObjectSerializerModifier.java

@Override
public BeanSerializerBuilder updateBuilder(SerializationConfig config, BeanDescription beanDesc,
        BeanSerializerBuilder builder) {

    for (BeanPropertyWriter writer : builder.getProperties()) {

        JavaType propertyType = writer.getMember().getType();
        Class<?> type = propertyType.getRawClass();
        List<BeanPropertyDefinition> properties = getProperties(propertyType, config);

        Optional.ofNullable(AnnotationUtils.findAnnotation(type, ValueObject.class))//
                .filter(it -> properties.size() == 1)//
                .flatMap(it -> properties.stream().findFirst())//
                .ifPresent(it -> writer.assignSerializer(new PropertyAccessingSerializer(it)));
    }/*w  w w . ja v  a2s . co m*/

    return builder;
}

From source file:org.lightadmin.core.web.json.DynamicFilePropertyOmittingSerializerModifier.java

@Override
public BeanSerializerBuilder updateBuilder(SerializationConfig config, BeanDescription beanDesc,
        BeanSerializerBuilder builder) {
    if (!configuration.isManagedDomainType(beanDesc.getBeanClass())) {
        return builder;
    }// ww  w  . ja  v a 2s .c  om

    PersistentEntity<?, ?> entity = configuration.forManagedDomainType(beanDesc.getBeanClass())
            .getPersistentEntity();

    List<BeanPropertyWriter> result = newArrayList();
    for (BeanPropertyWriter writer : builder.getProperties()) {
        PersistentProperty<?> persistentProperty = findProperty(writer.getName(), entity, beanDesc);

        if (persistentProperty == null) {
            result.add(writer);
            continue;
        }

        if (PersistentPropertyType.forPersistentProperty(persistentProperty) == FILE) {
            continue;
        }

        result.add(writer);
    }

    builder.setProperties(result);

    return builder;
}