Class SelfOrThis

java.lang.Object
org.biopax.paxtools.pattern.constraint.ConstraintAdapter
org.biopax.paxtools.pattern.constraint.SelfOrThis
All Implemented Interfaces:
Constraint

public class SelfOrThis extends ConstraintAdapter
When a constraint excludes the origin element, but it is needed to be among them, use this constraint. The wrapped constraint must have size 2.
Author:
Ozgun Babur
  • Constructor Details

    • SelfOrThis

      public SelfOrThis(Constraint con)
      Constructor with the wrapped constraint. Index of self is 0 by default.
      Parameters:
      con - wrapped constraint
    • SelfOrThis

      public SelfOrThis(Constraint con, int selfIndex)
      Constructor with the wrapped constraint and index of self. This index cannot map to the last element, but has to map one of the previous ones.
      Parameters:
      con - wrapped constraint
      selfIndex - index of self
  • Method Details

    • getVariableSize

      public int getVariableSize()
      Returns size of the wrapped constraint.
      Specified by:
      getVariableSize in interface Constraint
      Overrides:
      getVariableSize in class ConstraintAdapter
      Returns:
      size of the wrapped constraint
    • canGenerate

      public boolean canGenerate()
      This is a generative constraint.
      Specified by:
      canGenerate in interface Constraint
      Overrides:
      canGenerate in class ConstraintAdapter
      Returns:
      true
    • generate

      public Collection<BioPAXElement> generate(Match match, int... ind)
      Gets the first mapped element along with the generated elements of wrapped constraint.
      Specified by:
      generate in interface Constraint
      Overrides:
      generate in class ConstraintAdapter
      Parameters:
      match - current pattern match
      ind - mapped indices
      Returns:
      first mapped element along with the generated elements of wrapped constraint
    • satisfies

      public boolean satisfies(Match match, int... ind)
      Checks if the last index is either generated or equal to the first element.
      Specified by:
      satisfies in interface Constraint
      Overrides:
      satisfies in class ConstraintAdapter
      Parameters:
      match - current pattern match
      ind - mapped indices
      Returns:
      true if the last index is either generated or equal to the first element