Package org.kuali.rice.krms.api.engine
Interface TermResolver<T>
- Type Parameters:
T- the class of the resolved object
public interface TermResolver<T>
An TermResolver implementor is a utility class used for resolution (reification) of fact values for one or
moreTerms. There are a few key concepts to understand how TermResolvers function and work together.
- they can require prerequisite
Terms (which must not have any parameters). If they do, when theTermResolutionEnginecallsresolve(Map, Map)it will pass the resolved prerequisites in the first argument. - they can be chained. This means that if the
TermResolutionEnginehasTermResolvers (a <- b) and (b <- c), and you have the fact 'c', you can ask for term 'a' and the engine will chain the resolvers together to resolve it correctly. - they can be parameterized. If an TermResolver takes parameters, they must be declared via the
getParameterNames()method. All declared parameters are considered to be required. Parameters can be set on theTerm(via the constructor) that you are asking to resolve. When theTermResolutionEnginecallsresolve(Map, Map), the parameters will be passed in to the second argument. - Parameterized
TermResolvers can not be intermediates in a resolution plan. Another way to say this is that they can only be the last resolver in a chain. For example, say theTermResolutionEnginehasTermResolvers (a <- b) which takes no parameters, (b <- c) which takes a parameter "foo", and you have the fact 'c'. If you ask for Term 'a', the engine will not be able to resolve it because it would need to use a parameterized Term as an intermediate step in resolution, and that isn't allowed.
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Method Summary
Modifier and TypeMethodDescriptionintgetCost()Gets an int representing the cost of resolving the term. 1 is cheap, Integer.MAX_INT is expensive.Gets the name of the term that this TermResolver resolves.Gets the names of any parameters that thisTermResolverrequires to resolveTerms.Gets the names of the terms that this resolver requires in order to be able to resolve its output, or an empty set if it has no prereqs;Resolves the output term's fact value given the resolved prerequisite terms and term parameters.
-
Method Details
-
getPrerequisites
Gets the names of the terms that this resolver requires in order to be able to resolve its output, or an empty set if it has no prereqs;- Returns:
- the prerequisite term names
-
getOutput
String getOutput()Gets the name of the term that this TermResolver resolves.- Returns:
- the name of the term this TermResolver resolves.
-
getParameterNames
Gets the names of any parameters that thisTermResolverrequires to resolveTerms. This may be null if no parameters are required. If this is non-null/non-empty, then this resolver can not be used as an intermediate in a term resolution chain.- Returns:
- the names of parameters this TermResolver requires for resolution.
-
getCost
int getCost()Gets an int representing the cost of resolving the term. 1 is cheap, Integer.MAX_INT is expensive.- Returns:
- the cost.
-
resolve
T resolve(Map<String, Object> resolvedPrereqs, Map<String, throws TermResolutionExceptionString> parameters) Resolves the output term's fact value given the resolved prerequisite terms and term parameters. The term resolution engine will call this method providing the following parameters to the resolver:- Parameters:
resolvedPrereqs- the resolved prereqs. May be empty, but never null.parameters- any parameters on theTermto be resolved (which must match those declared viagetParameterNames(). May be empty, but never null.- Returns:
- the resolved fact value for the specified
Term. May be null. - Throws:
TermResolutionException
-