001package org.biopax.paxtools.pattern;
002
003import org.biopax.paxtools.model.BioPAXElement;
004
005import java.util.Collection;
006
007/**
008 * A constraint to check if a set of variables satisfy the requirements. If a constraint
009 * canGenerate, then it can generate possible values for the last variable, using the other
010 * variables.
011 *
012 * @author Ozgun Babur
013 */
014public interface Constraint
015{
016        /**
017         * Checks if the variables in the Match satisfies this constraint.
018         *
019         * @param match current pattern match
020         * @param ind mapped indices of the match
021         * @return true if this constraint is satisfied
022         */
023        public boolean satisfies(Match match, int ... ind);
024
025        /**
026         * Number of variables to check consistency. If this is a generative constraint, then the last
027         * variable is to be generated, and other are prerequisite.
028         *
029         * @return number of indexes this constraint uses
030         */
031        public int getVariableSize();
032        
033        /**
034         * Tells if this constraint is a generative constraint.
035         *
036         * @return true if constraint is generative
037         */
038        public boolean canGenerate();
039        
040        /**
041         * Generates candidate values for the variable to be generated.
042         *
043         * @param match current pattern match
044         * @param ind mapped indices
045         * @return generated values that satisfy this constraint
046         */
047        public Collection<BioPAXElement> generate(Match match, int ... ind);
048}