Interface ViatraQueryMatcher<Match extends IPatternMatch>
-
- Type Parameters:
Match
- the IPatternMatch type representing a single match of this pattern.
- All Known Implementing Classes:
BaseMatcher
,GenericPatternMatcher
public interface ViatraQueryMatcher<Match extends IPatternMatch>
Interface for a VIATRA Query matcher associated with a graph pattern.- No Implement:
- This interface is not intended to be implemented by clients. Implement BaseMatcher instead.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
countMatches()
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(java.util.function.Consumer<? super Match> processor)
Executes the given processor on each match of the pattern.void
forEachMatch(Match partialMatch, java.util.function.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(java.util.function.Consumer<? super Match> processor)
Executes the given processor on an arbitrarily chosen match of the pattern.boolean
forOneArbitraryMatch(Match partialMatch, java.util.function.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.java.util.Collection<Match>
getAllMatches()
Returns the set of all pattern matches.java.util.Collection<Match>
getAllMatches(Match partialMatch)
Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.java.util.Set<java.lang.Object>
getAllValues(java.lang.String parameterName)
Retrieve the set of values that occur in matches for the given parameterName.java.util.Set<java.lang.Object>
getAllValues(java.lang.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.ViatraQueryEngine
getEngine()
Returns the engine that the matcher uses.java.util.Optional<Match>
getOneArbitraryMatch()
Returns an arbitrarily chosen pattern match.java.util.Optional<Match>
getOneArbitraryMatch(Match partialMatch)
Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.java.util.List<java.lang.String>
getParameterNames()
Returns the array of symbolic parameter names.java.lang.String
getPatternName()
Fully qualified name of the pattern.java.lang.Integer
getPositionOfParameter(java.lang.String parameterName)
Returns the index of the symbolic parameter with the given name.IQuerySpecification<? extends ViatraQueryMatcher<Match>>
getSpecification()
The pattern that will be matched.boolean
hasMatch()
Indicates whether the query has any kind of matches.boolean
hasMatch(Match partialMatch)
Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, under any possible substitution of the unspecified parameters (if any).Match
newEmptyMatch()
Returns an empty, mutable Match for the matcher.Match
newMatch(java.lang.Object... parameters)
Returns a new (partial) Match object for the matcher.java.util.stream.Stream<Match>
streamAllMatches()
Returns a stream of all pattern matches.java.util.stream.Stream<Match>
streamAllMatches(Match partialMatch)
Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
-
-
-
Method Detail
-
getSpecification
IQuerySpecification<? extends ViatraQueryMatcher<Match>> getSpecification()
The pattern that will be matched.
-
getPatternName
java.lang.String getPatternName()
Fully qualified name of the pattern.
-
getPositionOfParameter
java.lang.Integer getPositionOfParameter(java.lang.String parameterName)
Returns the index of the symbolic parameter with the given name.
-
getParameterNames
java.util.List<java.lang.String> getParameterNames()
Returns the array of symbolic parameter names.
-
getAllMatches
java.util.Collection<Match> getAllMatches()
Returns the set of all pattern matches.- Returns:
- matches represented as a Match object.
-
getAllMatches
java.util.Collection<Match> getAllMatches(Match partialMatch)
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
java.util.stream.Stream<Match> 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
java.util.stream.Stream<Match> streamAllMatches(Match partialMatch)
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
java.util.Optional<Match> 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
java.util.Optional<Match> getOneArbitraryMatch(Match partialMatch)
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
boolean hasMatch(Match partialMatch)
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
int countMatches(Match partialMatch)
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
void forEachMatch(java.util.function.Consumer<? super Match> processor)
Executes the given processor on each match of the pattern.- Parameters:
processor
- the action that will process each pattern match.- Since:
- 2.0
-
forEachMatch
void forEachMatch(Match partialMatch, java.util.function.Consumer<? super Match> processor)
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
boolean forOneArbitraryMatch(java.util.function.Consumer<? super Match> processor)
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
boolean forOneArbitraryMatch(Match partialMatch, java.util.function.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. 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
Match newMatch(java.lang.Object... parameters)
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
java.util.Set<java.lang.Object> getAllValues(java.lang.String parameterName)
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
java.util.Set<java.lang.Object> getAllValues(java.lang.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.- 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
ViatraQueryEngine getEngine()
Returns the engine that the matcher uses.- Returns:
- the engine
-
-