/** * Matches the rules in this bucket against the given pattern that might contain * wildcards, i.e. '*' and '?'. * * @param pattern * The pattern. * @return The list of matching rules. * @throws NoRuleException * If the pattern did not contained any wildcard and the referenced * rule is not contained in the bucket. */ public List<T> match(String pattern) throws NoRuleException { List<T> matches = new ArrayList<>(); if (pattern.contains("?") || pattern.contains("*")) { for (Map.Entry<String, T> entry : rules.entrySet()) { if (FilenameUtils.wildcardMatch(entry.getKey(), pattern)) { matches.add(entry.getValue()); } } } else { matches.add(getById(pattern)); } return matches; }
public <B extends AbstractRuleBucket<T, NRE, DRE>> void add(B bucket) throws DRE { String id = null; try { for (String conceptId : bucket.getIds()) { id = conceptId; T rule = null; rule = bucket.getById(id); add(rule); } } catch (NoRuleException e) { throw new IllegalStateException("No rule of type " + getRuleTypeName() + " width " + id + " not found in overhanded bucket. The bucket is in an inconsistent state."); } } }