public boolean isIndexed() { return isList() || ContainerType.SEQ.equals(getContainerType()); }
@SuppressWarnings("unchecked") private Object convertArray(MappedPath propertyPath, Collection<? extends NODE> values, UID context) throws InstantiationException, IllegalAccessException { MappedProperty<?> mappedProperty = propertyPath.getMappedProperty(); Class<?> targetType = mappedProperty.getComponentType(); int size = values.size(); if (size == 1) { NODE node = values.iterator().next(); if (node instanceof ID) { if (mappedProperty.isList()) { values = convertList((ID) node, context); } else if (mappedProperty.isContainer()) { values = convertContainer((ID) node, context, mappedProperty.isIndexed()); } } // TODO else log error? } // TODO else log error? Object array = Array.newInstance(targetType, values.size()); int i = 0; for (NODE value : values) { if (value != null) { Array.set(array, i++, convertValue(value, targetType, propertyPath)); } else { Array.set(array, i++, null); } } return array; }
@SuppressWarnings("unchecked") private Object convertCollection(MappedPath propertyPath, Collection<? extends NODE> values, UID context) throws InstantiationException, IllegalAccessException { MappedProperty<?> mappedProperty = propertyPath.getMappedProperty(); Class<?> targetType = mappedProperty.getComponentType(); int size = values.size(); if (size == 1) { NODE node = values.iterator().next(); if (node instanceof ID) { if (mappedProperty.isList()) { values = convertList((ID) node, context); } else if (mappedProperty.isContainer()) { values = convertContainer((ID) node, context, mappedProperty.isIndexed()); } } // TODO else log error? } // TODO else log error? Class collectionType = mappedProperty.getCollectionType(); Collection collection = (Collection) collectionType.newInstance(); for (NODE value : values) { if (value != null) { collection.add(convertValue(value, targetType, propertyPath)); } else { collection.add(null); } } return collection; }
if (mappedPath.isReference() && !mappedPath.getPredicatePath().isEmpty()) { MappedProperty<?> property = mappedPath.getMappedProperty(); if (!property.isList()) { Class<?> type = property.getType(); if (property.isCollection() || property.isMap()) {
if (mappedProperty.isList()) { if (property.getRange().isEmpty()) { RDFSClass<?> componentType =