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 the TermResolutionEngine calls resolve(Map, Map) it will pass the resolved prerequisites in the first argument.
  • they can be chained. This means that if the TermResolutionEngine has TermResolvers (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 the Term (via the constructor) that you are asking to resolve. When the TermResolutionEngine calls resolve(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 the TermResolutionEngine has TermResolvers (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 Type
    Method
    Description
    int
    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 this TermResolver requires to resolve Terms.
    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;
    resolve(Map<String,Object> resolvedPrereqs, Map<String,String> parameters)
    Resolves the output term's fact value given the resolved prerequisite terms and term parameters.
  • Method Details

    • getPrerequisites

      Set<String> 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

      Set<String> getParameterNames()
      Gets the names of any parameters that this TermResolver requires to resolve Terms. 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,String> parameters) throws TermResolutionException
      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 the Term to be resolved (which must match those declared via getParameterNames(). May be empty, but never null.
      Returns:
      the resolved fact value for the specified Term. May be null.
      Throws:
      TermResolutionException