Interface RulesCatalog

  • All Known Implementing Classes:
    CompositeRulesCatalog, DefaultRulesCatalog

    public interface RulesCatalog
    Interface implemented by classes that manage and domains, rules and associated services.
    Author:
    Damien Carbonne
    • Method Detail

      • getDomains

        Set<String> getDomains()
        Returns:
        A set of all known domains.
      • hasDomain

        default boolean hasDomain​(String domain)
        Parameters:
        domain - The domain
        Returns:
        true if domain is known.
      • getRules

        Set<Rule> getRules()
        Returns:
        A set of all known Rules.
      • hasRule

        default boolean hasRule​(Rule rule)
        Returns true if a rule is registered.
        Parameters:
        rule - The rule
        Returns:
        true if rule is registered.
      • getRules

        default Set<Rule> getRules​(String domain)
        Returns a set of all known rules belonging to a domain.
        Parameters:
        domain - The domain.
        Returns:
        A set of rules belonging to domain.
      • getDescriptors

        <T> Set<IssuesDetector.Descriptor<T>> getDescriptors​(Class<T> dataClass)
        Returns a set of all Descriptors registered for a data class.
        Type Parameters:
        T - The data type.
        Parameters:
        dataClass - The data class.
        Returns:
        A set of all Descriptors registered for dataClass.
      • getDescriptor

        default <T> IssuesDetector.Descriptor<T> getDescriptor​(Rule rule,
                                                               Class<T> dataClass)
        Returns the IssuesDetector.Descriptor associated to a Rule and a Class.
        Type Parameters:
        T - The data type.
        Parameters:
        rule - The rule.
        dataClass - The data class.
        Returns:
        The IssuesDetector.Descriptor associated to rule and dataClass.
        Throws:
        cdc.util.lang.NotFoundException - When no matching Descriptor could be found.
      • hasDescriptor

        default boolean hasDescriptor​(Rule rule,
                                      Class<?> dataClass)
        Returns true if an IssuesDetector.Descriptor is registered for a Rule and a Class.
        Parameters:
        rule - The rule.
        dataClass - The data class
        Returns:
        true if an IssuesDetector.Descriptor is registered for rule and dataClass.
      • createIssuesDetector

        default <T> IssuesDetector<T> createIssuesDetector​(String project,
                                                           String snapshot,
                                                           ConfiguredRule configuredRule,
                                                           Class<T> dataClass)
        Creates and configures one IssuesDetector for one rule and parameters.
        Type Parameters:
        T - The data type.
        Parameters:
        project - The project for which the detector is created.
        snapshot - The snapshot for which the detector is created.
        configuredRule - The configured rule.
        dataClass - The data class.
        Returns:
        An IssueDetector matching configuredRule and dataClass, and configured with project and snapshot.
        Throws:
        cdc.util.lang.NotFoundException - When no matching IssuesDetector could be found.
      • apply

        default <T> void apply​(String project,
                               String snapshot,
                               ConfiguredRule configuredRule,
                               Class<T> dataClass,
                               Spliterator<LocatedData<T>> spliterator,
                               IssuesHandler<Issue> issuesHandler,
                               cdc.util.events.ProgressController controller)
        Creates and configures an appropriate IssuesDetector, and applies it to data provided by a Spliterator.
        Type Parameters:
        T - The data type.
        Parameters:
        project - The project for which the detector is created.
        snapshot - The snapshot for which the detector is created.
        configuredRule - The configured rule.
        dataClass - The data class.
        spliterator - The data spliterator.
        issuesHandler - The issues handler that will collect issues.
        controller - The progress controller.
      • apply

        default <T> void apply​(String project,
                               String snapshot,
                               Profile profile,
                               DataSource<T> source,
                               IssuesHandler<Issue> issuesHandler,
                               cdc.util.events.ProgressController controller)
        Checks all possible rules enabled in a profile and matching a data source.

        WARNING: A enabled rule for which no appropriate descriptor is declared in this catalog won't be checked.

        Type Parameters:
        T - The data type.
        Parameters:
        project - The project for which the detector is created.
        snapshot - The snapshot for which the detector is created.
        profile - The profile.
        source - The data source.
        issuesHandler - The issues handler that will collect issues.
        controller - The progress controller.
      • apply

        default void apply​(Project project,
                           IssuesHandler<Issue> issuesHandler,
                           cdc.util.events.ProgressController controller)
        Checks all data associated to a project with available enabled rules.
        Parameters:
        project - The project.
        issuesHandler - The issues handler that will collect issues.
        controller - The progress controller.
      • apply

        static <T> void apply​(IssuesDetector<T> detector,
                              Spliterator<LocatedData<T>> spliterator,
                              IssuesHandler<Issue> issuesHandler,
                              cdc.util.events.ProgressController controller)
        Applies an IssuesDetector to data provided by a Spliterator.
        Type Parameters:
        T - The data type.
        Parameters:
        detector - The detector.
        spliterator - The data spliterator.
        issuesHandler - The issues handler that will collect issues.
        controller - The progress controller.