Coverage Report - org.kuali.rice.krms.api.engine.TermResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
TermResolver
N/A
N/A
1
 
 1  
 package org.kuali.rice.krms.api.engine;
 2  
 
 3  
 import java.util.Map;
 4  
 import java.util.Set;
 5  
 
 6  
 /**
 7  
  * <p>An {@link TermResolver} implementor is a utility class used for resolution (reification) of {@link Term}s.  There are a
 8  
  * few key concepts to understand how {@link TermResolver}s function and work together.
 9  
  * </p>
 10  
  * <ul>
 11  
  * <li><b>they can require prerequisite {@link Term}s (which must not have any parameters)</b>.  If they do, when the {@link TermResolutionEngine} calls 
 12  
  * {@link #resolve(Map, Map)} it will pass the resolved prerequisites in the first argument.
 13  
  * <li><b>they can be chained.</b>  This means that if the {@link TermResolutionEngine} has {@link TermResolver}s (a &lt;- b) and 
 14  
  * (b &lt;- c), and you have the fact 'c', you can ask for term 'a' and the engine will chain the resolvers together
 15  
  * to resolve it correctly.</li>
 16  
  * <li><b>they can be parameterized.</b> If an TermResolver takes parameters, they must be declared via the
 17  
  * {@link #getParameterNames()} method.  All declared parameters are considered to be required.  Parameters can be set
 18  
  * on the {@link Term} (via the constructor) that you are asking to resolve. When the {@link TermResolutionEngine} calls 
 19  
  * {@link #resolve(Map, Map)}, the parameters will be passed in to the second argument.</li>
 20  
  * <li><b>Parameterized {@link TermResolver}s can not be intermediates in a resolution plan.</b>  Another way to say 
 21  
  * this is that they can only be the last resolver in a chain.  For example, say
 22  
  * the {@link TermResolutionEngine} has {@link TermResolver}s (a &lt;- b) which takes no parameters, 
 23  
  * (b &lt;- 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
 24  
  * it because it would need to use a parameterized Term as an intermediate step in resolution, and that isn't allowed.</li>
 25  
  * 
 26  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 27  
  *
 28  
  * @param <T> the class of the resolved object 
 29  
  */
 30  
 public interface TermResolver <T> {
 31  
         
 32  
         /**
 33  
          * @return the set of {@link TermSpecification}s that this resolver requires to resolve its output, or an empty set if it has no prereqs;
 34  
          */
 35  
         Set<TermSpecification> getPrerequisites();
 36  
         
 37  
         /**
 38  
          * @return the {@link TermSpecification} that the implementor resolves
 39  
          */
 40  
         TermSpecification getOutput();
 41  
         
 42  
         /**
 43  
          * 
 44  
          * @return the names of any parameters that this {@link TermResolver} requires to churn out values for multiple {@link Term}s.  This may 
 45  
          * be null if no parameters are required.  If this is non-null/non-empty, then this resolver can not be used as an intermediate
 46  
          * in a term resolution chain.
 47  
          */
 48  
         Set<String> getParameterNames();
 49  
         
 50  
         /**
 51  
          * @return an integer representing the cost of resolving the term. 1 is cheap, Integer.MAX_INT is expensive.
 52  
          */
 53  
         int getCost();
 54  
         
 55  
         /**
 56  
          * @param resolvedPrereqs the resolved prereqs
 57  
          * @param parameters any parameters on the {@link Term} to be resolved (which must match those declared via {@link #getParameterNames()} 
 58  
          * @return the resolved fact value for the specified {@link Term}
 59  
          * @throws TermResolutionException if something bad happens during the term resolution process
 60  
          */
 61  
         T resolve(Map<TermSpecification, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException;
 62  
 }