use of org.talend.hl7.Field in project atlasmap by atlasmap.
the class DocumentJavaFieldReader method extractFromCollection.
private Object extractFromCollection(AtlasInternalSession session, Object source, AtlasPath atlasPath) {
if (source == null) {
return null;
}
String lastSegment = atlasPath.getLastSegment();
if (!AtlasPath.isCollectionSegment(lastSegment) || !atlasPath.isIndexedCollection()) {
return source;
}
Integer index = atlasPath.getCollectionIndex(atlasPath.getLastSegment());
if (AtlasPath.isArraySegment(lastSegment)) {
return Array.get(source, index);
} else if (AtlasPath.isListSegment(lastSegment)) {
return Collection.class.cast(source).toArray()[index];
} else if (AtlasPath.isMapSegment(lastSegment)) {
// TODO support map key
String key = index.toString();
return Map.class.cast(source).get(key);
} else {
Field sourceField = session.head().getSourceField();
AtlasUtil.addAudit(session, sourceField.getDocId(), String.format("Ignoring unknown collection type in path '%s'", sourceField.getPath()), sourceField.getPath(), AuditStatus.WARN, null);
return source;
}
}
Aggregations