Class GenericPatternMatch

java.lang.Object
tools.refinery.interpreter.api.impl.BasePatternMatch
tools.refinery.interpreter.api.GenericPatternMatch
All Implemented Interfaces:
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 Details

    • get

      public Object get(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 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 interface IPatternMatch
      Overrides:
      get in class BasePatternMatch
    • set

      public boolean set(String parameterName, 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 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 class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • prettyPrint

      public 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, 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

      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.