Package tools.refinery.interpreter.api
Class GenericPatternMatch
java.lang.Object
tools.refinery.interpreter.api.impl.BasePatternMatch
tools.refinery.interpreter.api.GenericPatternMatch
- All Implemented Interfaces:
Cloneable
,IPatternMatch
Generic signature object implementation.
See also the generated matcher and signature of the pattern, with pattern-specific API simplifications.
- Since:
- 0.9
-
Method Summary
Modifier and TypeMethodDescriptionboolean
get
(int position) Returns the value of the parameter at the given position, or null if position is invalid.Returns the value of the parameter with the given name, or null if name is invalid.int
hashCode()
static GenericPatternMatch
newEmptyMatch
(GenericQuerySpecification<? extends GenericPatternMatcher> specification) Returns an empty, mutable match.static GenericPatternMatch
newMatch
(GenericQuerySpecification<? extends GenericPatternMatcher> specification, Object... parameters) Returns a new (partial) match.static GenericPatternMatch
newMutableMatch
(GenericQuerySpecification<? extends GenericPatternMatcher> specification, Object... parameters) Returns a mutable (partial) match.Prints the list of parameter-value pairs.boolean
Sets the parameter with the given name to the given value.GenericQuerySpecification
<? extends GenericPatternMatcher> Object[]
toArray()
Converts the match to an array representation, with each pattern parameter at their respective position.Takes an immutable snapshot of this match.Methods inherited from class tools.refinery.interpreter.api.impl.BasePatternMatch
isCompatibleWith, makeImmutableList, parameterNames, patternName, prettyPrintValue, set, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface tools.refinery.interpreter.api.IPatternMatch
isMutable
-
Method Details
-
get
Description copied from interface:IPatternMatch
Returns the value of the parameter with the given name, or null if name is invalid. -
get
Description copied from interface:IPatternMatch
Returns the value of the parameter at the given position, or null if position is invalid.- Specified by:
get
in interfaceIPatternMatch
- Overrides:
get
in classBasePatternMatch
-
set
Description copied from interface:IPatternMatch
Sets the parameter with the given name to the given value.Works only if match is mutable. See
IPatternMatch.isMutable()
. -
toArray
Description copied from interface:IPatternMatch
Converts the match to an array representation, with each pattern parameter at their respective position. In case of a partial match, unsubstituted parameters will be represented as null elements in the array.- Returns:
- a newly constructed array containing each parameter substitution of the match in order.
-
hashCode
public int hashCode() -
equals
-
prettyPrint
Description copied from interface:IPatternMatch
Prints the list of parameter-value pairs. -
specification
- Returns:
- the pattern for which this is a match.
-
newEmptyMatch
public static GenericPatternMatch newEmptyMatch(GenericQuerySpecification<? extends GenericPatternMatcher> specification) Returns an empty, mutable match. Fields of the mutable match can be filled to create a partial match, usable as matcher input.- Returns:
- the empty match
-
newMutableMatch
public static GenericPatternMatch newMutableMatch(GenericQuerySpecification<? extends GenericPatternMatcher> specification, Object... parameters) Returns a mutable (partial) match. Fields of the mutable match can be filled to create a partial match, usable as matcher input.- Parameters:
parameters
- the fixed value of pattern parameters, or null if not bound.- Returns:
- the new, mutable (partial) match object.
-
newMatch
public static GenericPatternMatch newMatch(GenericQuerySpecification<? extends GenericPatternMatcher> specification, Object... parameters) Returns a new (partial) match. This can be used e.g. to call the matcher with a partial match.The returned match will be immutable. Use
newEmptyMatch(GenericQuerySpecification)
to obtain a mutable match object.- Parameters:
parameters
- the fixed value of pattern parameters, or null if not bound.- Returns:
- the (partial) match object.
-
toImmutable
Description copied from interface:IPatternMatch
Takes an immutable snapshot of this match.- Returns:
- the match itself in case of immutable matches, an immutable copy in case of mutable ones.
-