configuration_file_parser.segment.ReasonerClassesParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brunner-core-parser Show documentation
Show all versions of brunner-core-parser Show documentation
Parser module for the BRunner project
The newest version!
package configuration_file_parser.segment;
import java.util.List;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import api.running.IToolKeywordsMenu;
import configuration_file_parser.ParserUtils;
import constants.BRunnerKeywords;
import constants.ToolsConstants;
/**
* Parser for the tool to use
*/
public class ReasonerClassesParser {
private static final Logger LOG = LoggerFactory.getLogger(ReasonerClassesParser.class);
/**
* @return the class name for the tool binding
* @param apacheConfigurationObject
* @throws ConfigurationException
* @throws ClassNotFoundException
*/
public static Class extends IToolKeywordsMenu> parse(Configuration apacheConfigurationObject)
throws ConfigurationException, ClassNotFoundException {
List optionsForReasoner = List.of(BRunnerKeywords.OuterLevel.REASONER.kw,
BRunnerKeywords.InnerLevel.META_REASONER.full);
Class extends IToolKeywordsMenu> found = null;
for (String option : optionsForReasoner) {
if (found == null) {
if (ParserUtils.checkPropertyValueExists(option, apacheConfigurationObject)) {
String classNicknameForOption = ParserUtils.popProperty(option, apacheConfigurationObject);
return ToolsConstants.getClassByName(classNicknameForOption);
}
}
}
//
var msg = "Keyword menu not found; check your classpath.";
var e = new ClassNotFoundException(msg);
LOG.error(msg, e);
throw e;
}
}