Class SameObjectPredicateFactory

java.lang.Object
fr.inria.rules.integraal.model.logicalElements.factory.impl.SameObjectPredicateFactory
All Implemented Interfaces:
fr.inria.rules.dlgpereader.builder.api.IPredicateFactory, PredicateFactory

public class SameObjectPredicateFactory extends Object implements PredicateFactory
This factory creates Predicates.
For each call at a 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 terms implementations used are immutable otherwise there could be unwanted side effects.
Author:
Florent Tornil
  • Constructor Details

    • SameObjectPredicateFactory

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

    • instance

      public static PredicateFactory instance()
      Returns the default instance of this factory.
      Returns:
      the default instance of this factory
    • createOrGetPredicate

      public Predicate createOrGetPredicate(String label, int arity)
      //////////////////////////////////////////////
      Specified by:
      createOrGetPredicate in interface fr.inria.rules.dlgpereader.builder.api.IPredicateFactory
      Specified by:
      createOrGetPredicate in interface PredicateFactory
      Parameters:
      label - the label
      arity - the arity
      Returns:
      a predicate with the given label and arity
    • createOrGetFreshPredicate

      public Predicate createOrGetFreshPredicate(int arity)
      Description copied from interface: PredicateFactory
      Creates a new predicate which won't be equal to another previously created predicate.
      The label of the predicate may already exist in some rare cases
      Specified by:
      createOrGetFreshPredicate in interface PredicateFactory
      Parameters:
      arity - the arity
      Returns:
      a fresh predicate with the given label and arity
    • forgetPredicate

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

      public Optional<Predicate> getPredicate(String label)
      Description copied from interface: PredicateFactory
      Gets a previously created predicate.
      This predicate will no longer be considered as already existing in the factory.
      Specified by:
      getPredicate in interface PredicateFactory
      Parameters:
      label - the label of the previously created predicate
      Returns:
      an optional that contains the predicate if there is one