Class AbstractCollectionOf
- java.lang.Object
-
- org.projog.core.predicate.builtin.compound.AbstractCollectionOf
-
- All Implemented Interfaces:
Predicate
- Direct Known Subclasses:
BagOf.BagOfPredicate,SetOf.SetOfPredicate
abstract class AbstractCollectionOf extends java.lang.Object implements Predicate
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractCollectionOf.KeyRepresents a combination of possible values for the variables contained in the goal.
-
Field Summary
Fields Modifier and Type Field Description private Termbagprivate Termgoalprivate java.util.Iterator<java.util.Map.Entry<AbstractCollectionOf.Key,java.util.List<Term>>>itrprivate PredicateFactorypfprivate Termtemplateprivate java.util.List<Variable>variablesNotInTemplate
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCollectionOf(PredicateFactory pf, Term template, Term goal, Term bag)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidadd(java.util.List<Term> l, Term t)booleancouldReevaluationSucceed()Could the next re-evaluation of this instance succeed?booleanevaluate()Attempts to satisfy the goal this instance represents.private java.util.List<Variable>getVariablesNotInTemplate(Term template, Term goal)private booleanhasFoundAnotherSolution(Predicate predicate)private voidinit(Term template, Term goal)
-
-
-
Field Detail
-
pf
private final PredicateFactory pf
-
template
private final Term template
-
goal
private final Term goal
-
bag
private final Term bag
-
variablesNotInTemplate
private java.util.List<Variable> variablesNotInTemplate
-
itr
private java.util.Iterator<java.util.Map.Entry<AbstractCollectionOf.Key,java.util.List<Term>>> itr
-
-
Constructor Detail
-
AbstractCollectionOf
protected AbstractCollectionOf(PredicateFactory pf, Term template, Term goal, Term bag)
-
-
Method Detail
-
evaluate
public final boolean evaluate()
Description copied from interface:PredicateAttempts 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()returnsfalsethen this method should only be called once per individual query (no attempt should be made to find alternative solutions).If
PredicateFactory.isRetryable()returnstruethen, in order to find all possible solutions for an individual query, this method should be recalled on backtracking until it returnsfalse.- Specified by:
evaluatein interfacePredicate- Returns:
trueif it was possible to satisfy the clause,falseotherwise- See Also:
PredicateFactory.getPredicate(Term[])
-
getVariablesNotInTemplate
private java.util.List<Variable> getVariablesNotInTemplate(Term template, Term goal)
-
hasFoundAnotherSolution
private boolean hasFoundAnotherSolution(Predicate predicate)
-
couldReevaluationSucceed
public final boolean couldReevaluationSucceed()
Description copied from interface:PredicateCould the next re-evaluation of this instance succeed?Specifies whether a specific instance of a specific implementation of
Predicate, that has already hadPredicate.evaluate()called on it at least once, could possibly returntruethe next timePredicate.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 thatPredicateFactory.isRetryable()deals with whether, in general, a specific implementation (rather than instance) ofPredicatecould ever produce multiple answers for an individual query.)- Specified by:
couldReevaluationSucceedin interfacePredicate- Returns:
trueif an attempt to re-evaluate this instance could possible succeed,falseotherwise
-
-