All Downloads are FREE. Search and download functionalities are using the official Maven repository.

configuration_file_parser.segment.ReasonerClassesParser Maven / Gradle / Ivy

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 parse(Configuration apacheConfigurationObject)
			throws ConfigurationException, ClassNotFoundException {

		List optionsForReasoner = List.of(BRunnerKeywords.OuterLevel.REASONER.kw,
				BRunnerKeywords.InnerLevel.META_REASONER.full);

		Class 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;

	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy