Class GenericPatternMatch
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch
-
- org.eclipse.viatra.query.runtime.api.GenericPatternMatch
-
- All Implemented Interfaces:
java.lang.Cloneable
,IPatternMatch
public abstract class GenericPatternMatch extends BasePatternMatch
Generic signature object implementation. See also the generated matcher and signature of the pattern, with pattern-specific API simplifications.- Since:
- 0.9
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.lang.Object
get(int position)
Returns the value of the parameter at the given position, or null if position is invalid.java.lang.Object
get(java.lang.String parameterName)
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, java.lang.Object... parameters)
Returns a new (partial) match.static GenericPatternMatch
newMutableMatch(GenericQuerySpecification<? extends GenericPatternMatcher> specification, java.lang.Object... parameters)
Returns a mutable (partial) match.java.lang.String
prettyPrint()
Prints the list of parameter-value pairs.boolean
set(java.lang.String parameterName, java.lang.Object newValue)
Sets the parameter with the given name to the given value.GenericQuerySpecification<? extends GenericPatternMatcher>
specification()
java.lang.Object[]
toArray()
Converts the match to an array representation, with each pattern parameter at their respective position.IPatternMatch
toImmutable()
Takes an immutable snapshot of this match.-
Methods inherited from class org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch
isCompatibleWith, makeImmutableList, parameterNames, patternName, prettyPrintFeature, prettyPrintValue, set, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.viatra.query.runtime.api.IPatternMatch
isMutable
-
-
-
-
Method Detail
-
get
public java.lang.Object get(java.lang.String parameterName)
Description copied from interface:IPatternMatch
Returns the value of the parameter with the given name, or null if name is invalid.
-
get
public java.lang.Object get(int position)
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
public boolean set(java.lang.String parameterName, java.lang.Object newValue)
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
public java.lang.Object[] 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()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
prettyPrint
public java.lang.String prettyPrint()
Description copied from interface:IPatternMatch
Prints the list of parameter-value pairs.
-
specification
public GenericQuerySpecification<? extends GenericPatternMatcher> 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, java.lang.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, java.lang.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
public IPatternMatch 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.
-
-