@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 (property.isList()) { removeList((ID) object, context); } else if (property.isContainer()) { removeContainer((ID) object, context); } else if (property.isContainer()) { ID container = toRDFContainer((Collection<?>) object, context, property.getContainerType()); if (container != null) {