Class SameObjectTermFactory

java.lang.Object
fr.inria.rules.integraal.model.logicalElements.factory.impl.SameObjectTermFactory
All Implemented Interfaces:
TermFactory

public class SameObjectTermFactory extends Object implements TermFactory
This factory creates terms. For each call at the same method with the same parameters, the same java object will be returned. Therefore, the equality test between those objects can be restricted to java object reference comparison (==). Please make sure the term implementations used are immutable otherwise there could be unwanted side effects.
Author:
Florent Tornil
  • Constructor Details

    • SameObjectTermFactory

      public SameObjectTermFactory()
      Creates a term factory with identity-based caching semantics.
  • Method Details

    • instance

      public static SameObjectTermFactory instance()
      Returns the default instance of this factory.
      Returns:
      the default instance of this factory
    • createOrGetConstant

      public Constant createOrGetConstant(String label)
      //////////////////////////////////////////////
      Specified by:
      createOrGetConstant in interface TermFactory
      Parameters:
      label - the label
      Returns:
      a constant with the given label
    • createOrGetLiteral

      public <T> Literal<T> createOrGetLiteral(T value)
      Description copied from interface: TermFactory
      Two object created by a call to this function with the same typed value argument must be equals according to the definition given by the Literal implementation used /!\ This method must not be used to create a number literal
      Specified by:
      createOrGetLiteral in interface TermFactory
      Type Parameters:
      T - the native type of the literal
      Parameters:
      value - the value
      Returns:
      a literal with the given value
    • createOrGetIntegerLiteral

      public <T extends Number> Literal<Long> createOrGetIntegerLiteral(T value)
      Description copied from interface: TermFactory
      Creates or reuses an integer literal from a numeric value.
      Specified by:
      createOrGetIntegerLiteral in interface TermFactory
      Type Parameters:
      T - the numeric type of the input value
      Parameters:
      value - the numeric value to convert
      Returns:
      a literal holding the integer value
    • createOrGetFloatLiteral

      public <T extends Number> Literal<Double> createOrGetFloatLiteral(T value)
      Description copied from interface: TermFactory
      Creates or reuses a floating-point literal from a numeric value.
      Specified by:
      createOrGetFloatLiteral in interface TermFactory
      Type Parameters:
      T - the numeric type of the input value
      Parameters:
      value - the numeric value to convert
      Returns:
      a literal holding the floating-point value
    • createOrGetVariable

      public Variable createOrGetVariable(String label)
      Description copied from interface: TermFactory
      Two objects created by a call to this function with the same label argument must be equals according to the definition given by the Variable implementation used
      Specified by:
      createOrGetVariable in interface TermFactory
      Parameters:
      label - the label
      Returns:
      a variable with the given label
    • createOrGetAnonymousVariable

      public Variable createOrGetAnonymousVariable()
      Description copied from interface: TermFactory
      Two objects created by a call to this function must never be equals according to the definition given by the Variable implementation used An anonymous Variable must not be equals to an existing Variable created by TermFactory.createOrGetVariable(String).
      Specified by:
      createOrGetAnonymousVariable in interface TermFactory
      Returns:
      a variable with a new label
    • createOrGetLogicalFunctionalTerm

      public LogicalFunctionalTerm createOrGetLogicalFunctionalTerm(String name, List<Term> terms)
      Description copied from interface: TermFactory
      Two objects created by a call to this function with the same label argument must be equals according to the definition given by the LogicalFunctionalTerm implementation used
      Specified by:
      createOrGetLogicalFunctionalTerm in interface TermFactory
      Parameters:
      name - the name of the function
      terms - the ordered arguments of the function
      Returns:
      a logical functional term with the given name and terms
    • createOrGetFreshVariable

      public Variable createOrGetFreshVariable()
      Description copied from interface: TermFactory
      Two objects created by a call to this function must never be equals according to the definition given by the Variable implementation used A Fresh Variable must not be equals to an existing Variable created by TermFactory.createOrGetVariable(String).
      Specified by:
      createOrGetFreshVariable in interface TermFactory
      Returns:
      a variable with a new label
    • createOrGetFreshConstant

      public Constant createOrGetFreshConstant()
      Description copied from interface: TermFactory
      Two objects created by a call to this function must never be equals according to the definition given by the Constant implementation used A Fresh Constant must not be equals to an existing Constant created by TermFactory.createOrGetConstant(String).
      Specified by:
      createOrGetFreshConstant in interface TermFactory
      Returns:
      a constant with a new label
    • forgetConstant

      public boolean forgetConstant(String label)
      Description copied from interface: TermFactory
      Forgets a previously created constant.
      This constant will no longer be considered as already existing in the factory.
      Specified by:
      forgetConstant in interface TermFactory
      Parameters:
      label - the label of the previously created constant
      Returns:
      true iff such a constant already exists in the factory, and thus forgets it.
    • createOrGetXsdLiteral

      public Literal<?> createOrGetXsdLiteral(String lexicalForm, String xsdType)
      Description copied from interface: TermFactory
      Builds a literal from a lexical string and an XSD type reference (e.g. "xsd:integer" or "http://www.w3.org/2001/XMLSchema#dateTime").

      The lexical string is parsed into a Java Object based on the XSD type, then stored in a Literal.

      Specified by:
      createOrGetXsdLiteral in interface TermFactory
      Parameters:
      lexicalForm - the lexical form to parse
      xsdType - the XSD type identifier
      Returns:
      the parsed literal
    • createOrGetXsdLiteral

      public Literal<?> createOrGetXsdLiteral(String lexicalForm, XsdDataType dataType)
      Description copied from interface: TermFactory
      Builds a literal from a lexical string and an XsdDataType.
      Specified by:
      createOrGetXsdLiteral in interface TermFactory
      Parameters:
      lexicalForm - the lexical form to parse
      dataType - the target datatype
      Returns:
      the parsed literal
    • getNullLiteral

      public Literal<?> getNullLiteral()
      Description copied from interface: TermFactory
      Gets the null literal value.
      Specified by:
      getNullLiteral in interface TermFactory
      Returns:
      the null literal