Example usage for org.springframework.data.mapping PersistentProperty isArray

List of usage examples for org.springframework.data.mapping PersistentProperty isArray

Introduction

In this page you can find the example usage for org.springframework.data.mapping PersistentProperty isArray.

Prototype

boolean isArray();

Source Link

Document

Returns whether the property is an array.

Usage

From source file:org.lightadmin.core.web.support.DynamicPersistentEntityResourceProcessor.java

private List<PersistentEntityWrapper> associatedPersistentEntities(Association association, Object instance) {
    PersistentProperty persistentProperty = association.getInverse();

    Object associationValue = beanWrapper(instance).getPropertyValue(persistentProperty.getName());
    if (associationValue == null) {
        return null;
    }/* w  w w  .  ja v  a  2 s  .c o  m*/

    List<PersistentEntityWrapper> result = newArrayList();

    if (persistentProperty.isArray()) {
        for (Object item : (Object[]) associationValue) {
            result.add(associatedPersistentEntity(persistentProperty, item));
        }
        return result;
    }

    for (Object item : (Iterable<Object>) associationValue) {
        result.add(associatedPersistentEntity(persistentProperty, item));
    }
    return result;
}