Class AtomImpl

java.lang.Object
fr.inria.rules.integraal.model.logicalElements.impl.AtomImpl
All Implemented Interfaces:
fr.inria.rules.dlgpemodel.api.formulas.IAtom, fr.inria.rules.dlgpemodel.api.formulas.IFormula, fr.inria.rules.dlgpemodel.api.formulas.IPredicated, fr.inria.rules.dlgpemodel.api.formulas.IStandardAtom, fr.inria.rules.dlgpemodel.api.sentences.IPrintable, FOFormula, Atom, Substitutable<FOFormula>, TermCompound, TermSequenceCompound

public class AtomImpl extends Object implements Atom
Default implementation of Atom
Author:
Florent Tornil
  • Constructor Details

    • AtomImpl

      public AtomImpl(Predicate predicate, List<Term> terms)
      Constructor with a list of terms
      Parameters:
      predicate - the predicate
      terms - the list of terms
    • AtomImpl

      public AtomImpl(Predicate predicate, Term... terms)
      Constructor with an array of terms
      Parameters:
      predicate - the predicate
      terms - the array of terms
  • Method Details

    • indexOf

      public int indexOf(Term term)
      //////////////////////////////////////////////
      Specified by:
      indexOf in interface Atom
      Parameters:
      term - the term to find
      Returns:
      the index of the first occurrence of Term term in this atom. Any negative non-zero value is returned if this atom does not contain the term.
    • contains

      public boolean contains(Term term)
      Description copied from interface: Atom
      Tests whether a term occurs in this atom.
      Specified by:
      contains in interface Atom
      Parameters:
      term - the term to check
      Returns:
      true iff the Term term is present in this atom.
    • indexesOf

      public int[] indexesOf(Term term)
      Description copied from interface: Atom
      Returns every position at which a term occurs in this atom.
      Specified by:
      indexesOf in interface Atom
      Parameters:
      term - the term to find all occurrences of
      Returns:
      the indexes of all the occurrence of Term term in this atom. An empty array is returned if this atom does not contain the term.
    • getTerm

      public Term getTerm(int index)
      Description copied from interface: TermSequenceCompound
      Returns the term at the given position in the sequence.
      Specified by:
      getTerm in interface TermSequenceCompound
      Parameters:
      index - the position of the term in the sequence
      Returns:
      the Term at the index position in the sequence.
    • getTermSequence

      public List<Term> getTermSequence()
      Description copied from interface: TermSequenceCompound
      Returns the direct term sequence of this compound.
      Specified by:
      getTermSequence in interface fr.inria.rules.dlgpemodel.api.formulas.IStandardAtom
      Specified by:
      getTermSequence in interface TermSequenceCompound
      Returns:
      the sequence of first level terms (i.e., all terms that are not themselves in a compound term) For instance, for p(a,g(b)), it returns a and g(b) but not b.
    • getPredicate

      public Predicate getPredicate()
      //////////////////////////////////////////////
      Specified by:
      getPredicate in interface Atom
      Specified by:
      getPredicate in interface fr.inria.rules.dlgpemodel.api.formulas.IPredicated
      Returns:
      the Predicate associated to this atom.
    • hashCode

      public int hashCode()
      //////////////////////////////////////////////
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a string representation of this atom of the form p(t1,...,tn)
    • applySubstitution

      public Atom applySubstitution(Substitution substitution, boolean evaluate)
      Description copied from interface: Atom
      Applies a substitution to this atom.
      Specified by:
      applySubstitution in interface Atom
      Specified by:
      applySubstitution in interface FOFormula
      Specified by:
      applySubstitution in interface Substitutable<FOFormula>
      Parameters:
      substitution - the substitution to apply
      evaluate - whether evaluable functions should be evaluated
      Returns:
      the substituted atom
    • copy

      public AtomImpl copy()
      Description copied from interface: FOFormula
      Creates a deep copy of this formula.
      Specified by:
      copy in interface FOFormula
      Returns:
      a detached copy of this formula