fileUtil.setup(pluginParameters);
WrapperFactory wrapperFactory = new WrapperFactoryImpl(fileUtil);
((WrapperFactoryImpl) wrapperFactory).setup(pluginParameters);
final XmlProcessor xmlProcessor = new XmlProcessor(wrapperFactory);
xmlProcessor.setup(pluginParameters);
if (sortAlfabeticalOnly) {
wrapperFactory = new WrapperFactory() {
@Override
public HierarchyWrapper createFromRootElement(final Element rootElement) {
return new HierarchyWrapper(new AlphabeticalSortedWrapper(rootElement));
}
@SuppressWarnings("unchecked")
@Override
public <T extends Content> Wrapper<T> create(final T content) {
if (content instanceof Element) {
Element element = (Element) content;
return (Wrapper<T>) new AlphabeticalSortedWrapper(element);
}
return new UnsortedWrapper<T>(content);
}
};
} else {
new ReflectionHelper(wrapperFactory).setField(fileUtil);
}
new ReflectionHelper(xmlProcessor).setField(wrapperFactory);
xmlProcessor.setOriginalXml(new ByteArrayInputStream(xml.getBytes(UTF_8)));
return xmlProcessor;
}