class AnalysisRuleProvider {

    @SuppressWarnings("unchecked")
    public Set<AnalysisRule> getRules() {
        if (rules == null) {
            rules = new HashSet<AnalysisRule>();

            final Enumeration<AnalysisRule> providersEnum = Service.providers(AnalysisRule.class);
            while (providersEnum.hasMoreElements())
                rules.add(providersEnum.nextElement());
        }

        return rules;
    }

}