Class Resolver

  • All Implemented Interfaces:
    com.yahoo.component.Component, java.lang.Comparable<com.yahoo.component.Component>
    Direct Known Subclasses:
    DeterministicResolver, RandomResolver

    public abstract class Resolver
    extends com.yahoo.component.AbstractComponent
    Superclass of page template choice resolvers.

    Subclasses overrides one of the two resolve methods to either resolve each choices individually or look at all choices at once.

    All subclasses of this must be multithread safe. I.e multiple calls may be made to resolve at the same time from different threads.

    Author:
    bratseth
    • Field Summary

      • Fields inherited from class com.yahoo.component.AbstractComponent

        isDeconstructable
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Resolver()  
        Resolver​(com.yahoo.component.ComponentId id)  
        Resolver​(java.lang.String id)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Resolution resolve​(Choice pageTemplate, Query query, Result result)
      Override this to resolve choices.
      void resolve​(Choice choice, Query query, Result result, Resolution resolution)
      Override this to resolve each choice independently.
      void resolve​(MapChoice choice, Query query, Result result, Resolution resolution)
      Override this to resolve each map choice independently.
      • Methods inherited from class com.yahoo.component.AbstractComponent

        clone, compareTo, deconstruct, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Resolver

        public Resolver​(java.lang.String id)
      • Resolver

        public Resolver​(com.yahoo.component.ComponentId id)
      • Resolver

        protected Resolver()
    • Method Detail

      • resolve

        public Resolution resolve​(Choice pageTemplate,
                                  Query query,
                                  Result result)
        Override this to resolve choices. Before retuning this method must resolve the given choice between a set of page templates and all choices found recursively within the chosen page template. It is permissible but not required to add solutions also to choices present within those templates which are not chosen.

        This default implementation creates a Resolution and calls resolve(choice/mapChoice,query,result,resolution) first on the given page template choice, then on each choice found in that temnplate. This provides a simple API to resolvers which make each choice independently.

        Parameters:
        pageTemplate - the choice of page templates to resolve - a choice containing singleton lists of PageTemplate elements
        query - the query, from which information useful for correct resolution can be found
        result - the result, from which further information useful for correct resolution can be found
        Returns:
        the resolution of the choices contained in the given page template
      • resolve

        public void resolve​(Choice choice,
                            Query query,
                            Result result,
                            Resolution resolution)
        Override this to resolve each choice independently. This default implementation does nothing.
        Parameters:
        choice - the choice to resolve
        query - the query for which this should be resolved, typically used to extract features
        result - the result for which this should be resolved, typically used to extract features
        resolution - the set of resolutions made so far, to which this should be added: resolution.addChoiceResolution(choice,chosenAlternativeIndex)
      • resolve

        public void resolve​(MapChoice choice,
                            Query query,
                            Result result,
                            Resolution resolution)
        Override this to resolve each map choice independently. This default implementation does nothing.
        Parameters:
        choice - the choice to resolve
        query - the query for which this should be resolved, typically used to extract features
        result - the result for which this should be resolved, typically used to extract features
        resolution - the set of resolutions made so far, to which this should be added: resolution.addMapChoiceResolution(choice,chosenMapping)