in camel-upgrade-recipes/src/main/java/org/apache/camel/upgrade/camel46/XmlDsl46Recipe.java [61:100]
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new AbstractCamelXmlVisitor() {
@Override
public Xml.Tag doVisitTag(final Xml.Tag tag, final ExecutionContext ctx) {
Xml.Tag t = super.doVisitTag(tag, ctx);
//save all properties into a list placed to the bean tag
//and the first property rename to properties and strip content
if (BEAN_PROPERTY_XPATH_MATCHER.matches(getCursor())) {
List<Xml.Tag> sb = getCursor().getParent().getMessage("properties");
if(sb == null) {
sb = new LinkedList<>();
getCursor().getParent().putMessage("properties", sb);
getCursor().getParent().putMessage("propertiesPrefix", t.getPrefix());
}
//make prefix bigger, as those values would come to the new nested level
sb.add(t.withPrefix(t.getPrefix() + " "));
//skip property
return null;
}
if (BEAN_XPATH_MATCHER.matches(getCursor()) && getCursor().getMessage("properties") != null) {
//save description into context for parent
List<Xml.Tag> sb = getCursor().getMessage("properties");
String prefix = getCursor().getMessage("propertiesPrefix");
if(sb != null) {
List<Content> content = new LinkedList<>();
content.addAll(t.getContent());
content.add(Xml.Tag.build("<properties/>").withPrefix(prefix).withContent(sb));
return t.withContent(content);
}
}
return t;
}
};
}