@SuppressWarnings("unchecked")
    private Collection<Object> loadChildren(FieldData field) {
        final Class<Collection<Object>> collectionType = (Class<Collection<Object>>) field.metaData.getType();
        final Collection<Object> values = instantiateCollectionType(collectionType);

        Resource parent = null;
        if (field.metaData.isReference()) {
            String referencedPath = resolvePropertyTypedValue(field, String.class);
            if (!isBlank(referencedPath)) {
                parent = resolveResource(referencedPath, Resource.class);
            }
        } else if (field.metaData.isPathAnnotationPresent()) {
            parent = resolveResource(field.path, Resource.class);
        } else {
            parent = this.resource;
        }

        if (parent == null) {
            return values;
        }

        final Class<?> targetType = field.metaData.getTypeParameter();
        Iterator<Resource> children = parent.listChildren();

        while (children.hasNext()) {
            Resource child = children.next();
            if (field.metaData.isResolveBelowEveryChildPathPresentOnChildren()) {
                // As specified via @Children(resolveBelowEveryChild = "...")
                child = child.getChild(field.metaData.getResolveBelowEveryChildPathOnChildren());
                if (child == null) {
                    continue;
                }
            }
            Object adapted = convert(child, targetType);
            if (adapted != null) {
                values.add(adapted);
            }
        }

        return values;
    }
@ SuppressWarnings ( "unchecked" ) private Collection < Object > loadChildren ( FieldData field ) { final Class < Collection < Object > > collectionType = ( Class < Collection < Object > > ) field . metaData . getType ( ) ; final Collection < Object > values = instantiateCollectionType ( collectionType ) ; Resource parent = null ; if ( field . metaData . isReference ( ) ) { String referencedPath = resolvePropertyTypedValue ( field , String . class ) ; if ( ! isBlank ( referencedPath ) ) { parent = resolveResource ( referencedPath , Resource . class ) ; } } else if ( field . metaData . isPathAnnotationPresent ( ) ) { parent = resolveResource ( field . path , Resource . class ) ; } else { parent = this . resource ; } if ( parent == null ) { return values ; } final Class < ? > targetType = field . metaData . getTypeParameter ( ) ; Iterator < Resource > children = parent . listChildren ( ) ; while ( children . hasNext ( ) ) { Resource child = children . next ( ) ; if ( field . metaData . isResolveBelowEveryChildPathPresentOnChildren ( ) ) { child = child . getChild ( field . metaData . getResolveBelowEveryChildPathOnChildren ( ) ) ; if ( child == null ) { continue ; } } Object adapted = convert ( child , targetType ) ; if ( adapted != null ) { values . add ( adapted ) ; } } return values ; }
Loads the children fo a field annotated with {@link io.neba.api.annotations.Children}.
Resolves the parent who's children are to be loaded (this might e.g. be a {@link io.neba.api.annotations.Reference referenced} resource).
Loads all children of the respective parent resource, {@link #convert(org.apache.sling.api.resource.Resource, Class) adapts}
them if required, and adds them to a newly create collection compatible to the
{@link io.neba.core.resourcemodels.metadata.MappedFieldMetaData#getType() field type}, if the adaptation result is not
<code>null</code>.

@return never null but rather an empty collection.