Package tools.refinery.interpreter.api
Interface InterpreterMatcher<Match extends IPatternMatch>
- Type Parameters:
Match
- the IPatternMatch type representing a single match of this pattern.
- All Known Implementing Classes:
BaseMatcher
,GenericPatternMatcher
public interface InterpreterMatcher<Match extends IPatternMatch>
Interface for a Refinery Interpreter matcher associated with a graph pattern.
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the number of all pattern matches.int
countMatches
(Match partialMatch) Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.void
forEachMatch
(Consumer<? super Match> processor) Executes the given processor on each match of the pattern.void
forEachMatch
(Match partialMatch, Consumer<? super Match> processor) Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters.boolean
forOneArbitraryMatch
(Consumer<? super Match> processor) Executes the given processor on an arbitrarily chosen match of the pattern.boolean
forOneArbitraryMatch
(Match partialMatch, Consumer<? super Match> processor) Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.Returns the set of all pattern matches.getAllMatches
(Match partialMatch) Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.getAllValues
(String parameterName) Retrieve the set of values that occur in matches for the given parameterName.getAllValues
(String parameterName, Match partialMatch) Retrieve the set of values that occur in matches for the given parameterName, that conforms to the given fixed values of some parameters.Returns the engine that the matcher uses.Returns an arbitrarily chosen pattern match.getOneArbitraryMatch
(Match partialMatch) Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.Returns the array of symbolic parameter names.Fully qualified name of the pattern.getPositionOfParameter
(String parameterName) Returns the index of the symbolic parameter with the given name.IQuerySpecification
<? extends InterpreterMatcher<Match>> The pattern that will be matched.boolean
hasMatch()
Indicates whether the query has any kind of matches.boolean
Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, under any possible substitution of the unspecified parameters (if any).Returns an empty, mutable Match for the matcher.Returns a new (partial) Match object for the matcher.Returns a stream of all pattern matches.streamAllMatches
(Match partialMatch) Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
-
Method Details
-
getSpecification
IQuerySpecification<? extends InterpreterMatcher<Match>> getSpecification()The pattern that will be matched. -
getPatternName
String getPatternName()Fully qualified name of the pattern. -
getPositionOfParameter
Returns the index of the symbolic parameter with the given name. -
getParameterNames
Returns the array of symbolic parameter names. -
getAllMatches
Collection<Match> getAllMatches()Returns the set of all pattern matches.- Returns:
- matches represented as a Match object.
-
getAllMatches
Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.- Parameters:
partialMatch
- a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.- Returns:
- matches represented as a Match object.
-
streamAllMatches
Returns a stream of all pattern matches.WARNING If the result set changes while the stream is evaluated, the set of matches included in the stream are unspecified. In such cases, either rely on
getAllMatches()
or collect the results of the stream in end-user code.- Returns:
- matches represented as a Match object.
- Since:
- 2.0
-
streamAllMatches
Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.WARNING If the result set changes while the stream is evaluated, the set of matches included in the stream are unspecified. In such cases, either rely on
getAllMatches()
or collect the results of the stream in end-user code.- Parameters:
partialMatch
- a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.- Returns:
- matches represented as a Match object.
- Since:
- 2.0
-
getOneArbitraryMatch
Returns an arbitrarily chosen pattern match. Neither determinism nor randomness of selection is guaranteed.- Returns:
- a match represented as a Match object, or an empty Optional if no match is found.
- Since:
- 2.0
-
getOneArbitraryMatch
Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. Neither determinism nor randomness of selection is guaranteed.- Parameters:
partialMatch
- a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.- Returns:
- a match represented as a Match object, or an empty Optional if no match is found.
- Since:
- 2.0
-
hasMatch
boolean hasMatch()Indicates whether the query has any kind of matches.- Returns:
- true if there exists a valid match of the pattern.
- Since:
- 1.7
-
hasMatch
Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, under any possible substitution of the unspecified parameters (if any).- Parameters:
partialMatch
- a (partial) match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.- Returns:
- true if the input is a valid (partial) match of the pattern.
-
countMatches
int countMatches()Returns the number of all pattern matches.- Returns:
- the number of pattern matches found.
-
countMatches
Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.- Parameters:
partialMatch
- a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.- Returns:
- the number of pattern matches found.
-
forEachMatch
Executes the given processor on each match of the pattern.- Parameters:
processor
- the action that will process each pattern match.- Since:
- 2.0
-
forEachMatch
Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters.- Parameters:
partialMatch
- array where each non-null element binds the corresponding pattern parameter to a fixed value.processor
- the action that will process each pattern match.- Since:
- 2.0
-
forOneArbitraryMatch
Executes the given processor on an arbitrarily chosen match of the pattern. Neither determinism nor randomness of selection is guaranteed.- Parameters:
processor
- the action that will process the selected match.- Returns:
- true if the pattern has at least one match, false if the processor was not invoked
- Since:
- 2.0
-
forOneArbitraryMatch
Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. Neither determinism nor randomness of selection is guaranteed.- Parameters:
partialMatch
- array where each non-null element binds the corresponding pattern parameter to a fixed value.processor
- the action that will process the selected match.- Returns:
- true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- Since:
- 2.0
-
newEmptyMatch
Match newEmptyMatch()Returns an empty, mutable Match for the matcher. Fields of the mutable match can be filled to create a partial match, usable as matcher input. This can be used to call the matcher with a partial match even if the specific class of the matcher or the match is unknown.- Returns:
- the empty match
-
newMatch
Returns a new (partial) Match object for the matcher. This can be used e.g. to call the matcher with a partial match.The returned match will be immutable. Use
newEmptyMatch()
to obtain a mutable match object.- Parameters:
parameters
- the fixed value of pattern parameters, or null if not bound.- Returns:
- the (partial) match object.
-
getAllValues
Retrieve the set of values that occur in matches for the given parameterName.- Parameters:
parameterName
- name of the parameter for which values are returned- Returns:
- the Set of all values for the given parameter, null if the parameter with the given name does not exists, empty set if there are no matches
-
getAllValues
Retrieve the set of values that occur in matches for the given parameterName, that conforms to the given fixed values of some parameters.- Parameters:
parameterName
- name of the parameter for which values are returnedpartialMatch
- a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.- Returns:
- the Set of all values for the given parameter, null if the parameter with the given name does not exists or if the parameter with the given name is set in partialMatch, empty set if there are no matches
-
getEngine
InterpreterEngine getEngine()Returns the engine that the matcher uses.- Returns:
- the engine
-