use of org.apache.commons.collections4.keyvalue.DefaultMapEntry in project alien4cloud by alien4cloud.
the class AbstractTypeNodeParser method findWrapperPropertyByPath.
/**
* For example:
* <ul>
* <li>.something : the value will be set to the property of root named 'something'
* <li>child1.child2.prop : the value will be mapped u getChild1().getChild2().setProp()
* </ul>
*/
private Entry<BeanWrapper, String> findWrapperPropertyByPath(BeanWrapper root, BeanWrapper current, String path) {
int dotIdx = path.indexOf(".");
if (dotIdx < 0) {
return new DefaultMapEntry<BeanWrapper, String>(current, path);
}
BeanWrapper base = current;
String nextPath = path;
if (path.startsWith("../")) {
base = new BeanWrapperImpl(ParsingContextExecution.getParent(current));
nextPath = path.substring(3);
} else if (path.startsWith(".")) {
base = root;
nextPath = path.substring(1);
} else {
String wrapperCandidateName = path.substring(0, path.indexOf("."));
Object wrapperCandidate = current.getPropertyValue(wrapperCandidateName);
base = new BeanWrapperImpl(wrapperCandidate);
nextPath = path.substring(path.indexOf(".") + 1);
}
return findWrapperPropertyByPath(root, base, nextPath);
}
Aggregations