}
VectorWithOrdinal vord = getVectorWithOrdinal(seg.isArray() ? null : seg.getNameSegment().getPath());
if (vord == null) return null;
ValueVector v = vord.vector;
if (addToBreadCrumb) {
builder.intermediateType(v.getField().getType());
builder.addId(vord.ordinal);
}
if (v instanceof AbstractContainerVector) {
// we're looking for a multi path.
AbstractContainerVector c = (AbstractContainerVector) v;
return c.getFieldIdIfMatches(builder, addToBreadCrumb, seg.getChild());
} else {
if (seg.isNamed()) {
if(addToBreadCrumb) builder.intermediateType(v.getField().getType());
builder.finalType(v.getField().getType());
} else {
builder.finalType(v.getField().getType().toBuilder().setMode(DataMode.OPTIONAL).build());
}
if (seg.isLastPath()) {
return builder.build();
} else {
PathSegment child = seg.getChild();
if (child.isLastPath() && child.isArray()) {
if (addToBreadCrumb) {
builder.remainder(child);
}
builder.withIndex();
builder.finalType(v.getField().getType().toBuilder().setMode(DataMode.OPTIONAL).build());
return builder.build();
} else {
logger.warn("You tried to request a complex type inside a scalar object or path or type is wrong.");
return null;
}