Class AbstractSubstitution

java.lang.Object
fr.lirmm.graphik.integraal.core.AbstractSubstitution
All Implemented Interfaces:
Substitution, Comparable<Substitution>
Direct Known Subclasses:
AbstractMapBasedSubstitution, EmptySubstitution, VariablePrefixSubstitution, VariableRemovePrefixSubstitution

public abstract class AbstractSubstitution extends Object implements Substitution
Base implementation of Substitution with shared image and composition logic.
Author:
Clément Sipieter (INRIA) <clement@6pi.fr>
  • Constructor Details

    • AbstractSubstitution

      protected AbstractSubstitution()
      Creates an abstract substitution base implementation.
  • Method Details

    • createImageOf

      public List<Term> createImageOf(Collection<? extends Term> terms)
      Description copied from interface: Substitution
      Get the image of each terms of the specified list.
      Specified by:
      createImageOf in interface Substitution
      Parameters:
      terms - the terms to substitute
      Returns:
      A list of images of each terms.
    • put

      public boolean put(Substitution substitution)
      Description copied from interface: Substitution
      Add all mappings from an other substitution instance. Returns false if there already exists an other image for a variable from the domain of s, true otherwise.
      Specified by:
      put in interface Substitution
      Parameters:
      substitution - the substitution whose mappings should be inserted
      Returns:
      false if there already exists an other image for a variable from the domain of s, true otherwise.
    • createImageOf

      public Atom createImageOf(Atom atom)
      Description copied from interface: Substitution
      Apply this substitution on an atom.
      Specified by:
      createImageOf in interface Substitution
      Parameters:
      atom - (const)
      Returns:
      an Atom which is the image of specified one by this substitution.
    • createImageOf

      public InMemoryAtomSet createImageOf(AtomSet src) throws AtomSetException
      Description copied from interface: Substitution
      Apply this substitution on an atom set.
      Specified by:
      createImageOf in interface Substitution
      Parameters:
      src - (const)
      Returns:
      an InMemoryAtomSet which is the image of specified one by this substitution.
      Throws:
      AtomSetException - if the image cannot be computed
    • createImageOf

      public InMemoryAtomSet createImageOf(InMemoryAtomSet src)
      Description copied from interface: Substitution
      Apply this substitution on an atom set.
      Specified by:
      createImageOf in interface Substitution
      Parameters:
      src - (const)
      Returns:
      an InMemoryAtomSet which is the image of specified one by this substitution.
    • apply

      public void apply(AtomSet src, AtomSet dest) throws AtomSetException
      Description copied from interface: Substitution
      Insert the application of this substitution on the src atom set into the target atom set.
      Specified by:
      apply in interface Substitution
      Parameters:
      src - (const)
      dest - the atom set receiving the substituted atoms
      Throws:
      AtomSetException - if the substituted atoms cannot be inserted
    • apply

      public void apply(InMemoryAtomSet src, InMemoryAtomSet dest)
      Description copied from interface: Substitution
      Insert the application of this substitution on the src atom set into the target atom set.
      Specified by:
      apply in interface Substitution
      Parameters:
      src - (const)
      dest - the atom set receiving the substituted atoms
    • createImageOf

      public Rule createImageOf(Rule rule)
      Description copied from interface: Substitution
      Apply this substitution on the given rule.
      Specified by:
      createImageOf in interface Substitution
      Parameters:
      rule - (const)
      Returns:
      an Rule which is the image of specified one by this substitution.
    • createImageOf

      public ConjunctiveQuery createImageOf(ConjunctiveQuery cq)
      Description copied from interface: Substitution
      Apply this substitution on the given conjunctive query.
      Specified by:
      createImageOf in interface Substitution
      Parameters:
      cq - (const)
      Returns:
      an conjunctive query which is the image of specified one by this substitution.
    • compose

      public boolean compose(Variable term, Term substitut)
      Description copied from interface: Substitution
      For example, if the current substitution is {Y -> Z} and you compose it with {X -> Y, V -> U}, the result is {X -> Z, Y -> Z, V -> U}.
      Specified by:
      compose in interface Substitution
      Parameters:
      term - the variable to compose
      substitut - the image to compose with
      Returns:
      true if the composition succeeds, false otherwise
    • compose

      public Substitution compose(Substitution s)
      Description copied from interface: Substitution
      (CONST)
      This method construct a new Substitution which is the composition of this substitution with the specified one. For example, if the current substitution is {Y -> Z} and you compose it with {X -> Y, V -> U}, the result is {X -> Z, Y -> Z, V -> U}.
      Specified by:
      compose in interface Substitution
      Parameters:
      s - the substitution to compose with this one
      Returns:
      the composed substitution
    • aggregate

      public Substitution aggregate(Substitution s)
      Description copied from interface: Substitution
      (const) This method construct a new Substitution which is the aggregation of this substitution with the specified one.
      Specified by:
      aggregate in interface Substitution
      Parameters:
      s - the substitution to aggregate with this one
      Returns:
      null, if the aggregation put two constants into a same connected component.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • appendTo

      public void appendTo(StringBuilder sb)
    • equals

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

      public boolean equals(Substitution other)
      Compares this substitution with another one by domain, codomain, and images.
      Parameters:
      other - the substitution to compare with
      Returns:
      true if both substitutions are equivalent
    • compareTo

      public int compareTo(Substitution other)
      Specified by:
      compareTo in interface Comparable<Substitution>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object