Class RuleBase

  • Direct Known Subclasses:
    AdaptableRuleBase

    public class RuleBase
    extends java.lang.Object
    An RuleBase is associated to an EventRealm and it is responsible for creating, managing and disposing rules in the Rule Engine. It provides an unmodifiable view for the collection of applicable activations.
    • Method Detail

      • instantiateRule

        protected <EventAtom> RuleInstance<EventAtom> instantiateRule​(RuleSpecification<EventAtom> specification,
                                                                      EventFilter<? super EventAtom> filter)
        Instantiates the given specification over the EventRealm of the RuleBase. If the specification was already instantiated, the existing instance is returned.
        Parameters:
        specification - the rule to be instantiated
        Returns:
        the created or existing rule instance
      • removeRule

        protected <EventAtom> boolean removeRule​(RuleInstance<EventAtom> instance)
        Removes and disposes of a rule instance.
        Parameters:
        instance -
        Returns:
        true, if the instance was part of the RuleBase
      • removeRule

        protected <EventAtom> boolean removeRule​(RuleSpecification<EventAtom> specification,
                                                 EventFilter<? super EventAtom> filter)
        Removes and disposes of a rule instance with the given specification.
        Parameters:
        specification -
        filter - the partial match used as filter
        Returns:
        true, if the specification had an instance in the RuleBase
      • dispose

        protected void dispose()
        Disposes of each rule instance managed by the agenda.
      • getEventRealm

        public EventRealm getEventRealm()
      • getRuleSpecificationMultimap

        public java.util.Map<RuleSpecification<?>,​java.util.Set<EventFilter<?>>> getRuleSpecificationMultimap()
        Since:
        2.0
      • getRuleInstances

        public java.util.Set<RuleInstance<?>> getRuleInstances()
        Returns:
        an immutable copy of the set of rule instances
      • getInstance

        public <EventAtom> RuleInstance<EventAtom> getInstance​(RuleSpecification<EventAtom> specification,
                                                               EventFilter<? super EventAtom> filter)
        Returns the filtered instance managed by the RuleBase for the given specification.
        Parameters:
        specification -
        filter - the partial match to be used as filter
        Returns:
        the instance, if it exists, null otherwise
      • createScopedConflictSet

        public ScopedConflictSet createScopedConflictSet​(ConflictResolver conflictResolver,
                                                         java.util.Map<RuleSpecification<?>,​java.util.Set<EventFilter<?>>> specifications)
        Creates a scoped conflict set of the enabled activations of the provided rule specifications and filters using the given conflict resolver. The set will be incrementally updated until disposed.
        Parameters:
        conflictResolver -
        specifications -
        Since:
        2.0
      • getAgenda

        public Agenda getAgenda()
      • getLogger

        public org.apache.log4j.Logger getLogger()