use of org.batfish.z3.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;
}
}
use of org.batfish.z3.Field in project batfish by batfish.
the class VariableSizeCollector method visitVarIntExpr.
@Override
public void visitVarIntExpr(VarIntExpr varIntExpr) {
Field field = varIntExpr.getField();
_variableSizes.add(Maps.immutableEntry(field.getName(), field.getSize()));
}
Aggregations