use of com.liferay.ide.idea.util.SwitchConsumer.SwitchConsumerBuilder in project liferay-ide by liferay.
the class LiferayModuleFragmentBuilder method setupRootModel.
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
VirtualFile projectRoot = _createAndGetContentEntry();
Project project = rootModel.getProject();
ProjectType liferayProjectType = LiferayProjectTypeService.getProjectType(project);
_createProject(projectRoot, liferayProjectType.getId());
File hostBundle = new File(LiferayIdeaUI.USER_BUNDLES_DIR, _fragmentHost.substring(0, _fragmentHost.lastIndexOf(".jar")));
SwitchConsumerBuilder<File> switch_ = SwitchConsumer.newBuilder();
SwitchConsumer<File> switchConsumer = switch_.addCase(f -> f.getName().equals("portlet.properties"), f -> _copyPortletExtProperties(projectRoot, f)).addCase(f -> f.getName().contains("default.xml"), f -> _createDefaultExtXmlFile(projectRoot, f)).setDefault(f -> _copyOtherResource(projectRoot, f)).build();
Stream<String> stream = Stream.of(_overrideFiles);
stream.map(overrideFile -> new File(hostBundle, overrideFile)).filter(file -> file.exists()).forEach(switchConsumer);
rootModel.addContentEntry(projectRoot);
if (myJdk != null) {
rootModel.setSdk(myJdk);
} else {
rootModel.inheritSdk();
}
}
Aggregations