Class Nth.Retryable

  • All Implemented Interfaces:
    Predicate
    Enclosing class:
    Nth

    private class Nth.Retryable
    extends java.lang.Object
    implements Predicate
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int ctr  
      (package private) Term element  
      (package private) Term index  
      (package private) Term list  
    • Constructor Summary

      Constructors 
      Constructor Description
      Retryable​(Term index, Term list, Term element)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void backtrack​(Term index, Term list, Term element)  
      boolean couldReevaluationSucceed()
      Could the next re-evaluation of this instance succeed?
      boolean evaluate()
      Attempts to satisfy the goal this instance represents.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • index

        final Term index
      • element

        final Term element
      • ctr

        int ctr
    • Constructor Detail

      • Retryable

        Retryable​(Term index,
                  Term list,
                  Term element)
    • Method Detail

      • evaluate

        public boolean evaluate()
        Description copied from interface: Predicate
        Attempts to satisfy the goal this instance represents.

        Calling this method multiple times on a single instance allows all possible answers to be identified. An attempt to find a solution carries on from where the last successful call finished.

        If PredicateFactory.isRetryable() returns false then this method should only be called once per individual query (no attempt should be made to find alternative solutions).

        If PredicateFactory.isRetryable() returns true then, in order to find all possible solutions for an individual query, this method should be recalled on backtracking until it returns false.

        Specified by:
        evaluate in interface Predicate
        Returns:
        true if it was possible to satisfy the clause, false otherwise
        See Also:
        PredicateFactory.getPredicate(Term[])
      • backtrack

        private void backtrack​(Term index,
                               Term list,
                               Term element)
      • couldReevaluationSucceed

        public boolean couldReevaluationSucceed()
        Description copied from interface: Predicate
        Could the next re-evaluation of this instance succeed?

        Specifies whether a specific instance of a specific implementation of Predicate, that has already had Predicate.evaluate() called on it at least once, could possibly return true the next time Predicate.evaluate() is called on it. i.e. is it worth trying to continue to find solutions for the specific query this particular instance represents and has been evaluating?

        (Note: the difference between this method and PredicateFactory.isRetryable() is that PredicateFactory.isRetryable() deals with whether, in general, a specific implementation (rather than instance) of Predicate could ever produce multiple answers for an individual query.)

        Specified by:
        couldReevaluationSucceed in interface Predicate
        Returns:
        true if an attempt to re-evaluate this instance could possible succeed, false otherwise