org.jharks.workflow.Rule Maven / Gradle / Ivy
package org.jharks.workflow;
import java.util.List;
/**
* The Rule class is an abstract class with a factory method that
* allows for the instantiation of various rule implementations. This
* ultimately allows for new Rule implementations to be written
* and then plugged into the architecture by simply modifying the workflow
* XML configuration file.
*
* @author Michael J. Rizzo
* @version 1.0
*/
public abstract class Rule {
/**
* Check to see if rule applies according to provided input.
* @param input the submitted input.
* @return boolean indicating whether rule was applied or not.
*/
public abstract boolean checkRule(Object input);
/**
* Abstract method to be implemented by all Rule
* implementations to allow for the retrieval of RuleCondition
* instances that may be part of a Rule instance.
* @return the conditions of the Rule.
*/
public abstract List getRuleConditions();
/**
* Add condition to conditions map. Performed at initialization time by digester.
* @param rc the RuleCondition instance to be added to the rule conditions map.
*/
public abstract void addRuleCondition(RuleCondition rc);
/**
* Factory method for creation of Rule implementations.
* @param ruleImplName the class name of rule implementation to be
* instantiated.
* @return an instance of a Rule object.
* @throws ClassNotFoundException if can not find classname specified.
* @throws IllegalAccessException if the protection on object constructor
* is violated.
* @throws InstantiationException if error occurs while instantiating
* the object.
*/
public static Rule getRuleInstance(String ruleImplName)
throws ClassNotFoundException,
IllegalAccessException,
InstantiationException {
return (Rule) Class.forName(ruleImplName).newInstance();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy