use of org.osgi.dto.DTO in project felix by apache.
the class SchemaBasedConverter method convertMap.
@SuppressWarnings("unchecked")
private T convertMap(Map<?, ?> map, Schema s, String contextPath) {
Node node = s.nodeAtPath(contextPath);
Class<?> cls = Util.rawClassOf(node.type());
if (!asDTO(cls))
return handleInvalid();
if (!contextPath.endsWith("/"))
contextPath = contextPath + "/";
return (T) convertToDTO((Class<? extends DTO>) cls, map, s, contextPath);
}
use of org.osgi.dto.DTO in project felix by apache.
the class SchemaBasedConverter method convertToCollection.
@SuppressWarnings({ "rawtypes", "unchecked" })
private <U, V extends Collection<U>> V convertToCollection(Class<U> targetCls, Class<V> collectionClass, Collection sourceCollection, Schema schema, String path) {
try {
V targetCollection = instantiateCollection(collectionClass);
sourceCollection.stream().map(obj -> convertCollectionItemToObject(obj, targetCls, schema, path)).forEach(u -> targetCollection.add((U) u));
return targetCollection;
} catch (Exception e) {
throw new ConversionException("Cannot create DTO " + targetCls, e);
}
}
Aggregations