@Nullable public RuleType matchingRule(ProtoElement elem){
  RuleType result=ruleMap.get(elem);
  if (result != null) {
    return result;
  }
  for (int i=rules.size() - 1; i >= 0; i--) {
    RuleWrapper<RuleType> ruleWrapper=rules.get(i);
    String matchedSelector=ruleWrapper.getMatchedSelector(elem);
    if (matchedSelector != null) {
      ruleMap.put(elem,ruleWrapper.rule);
      if (unmatchedRules.containsKey(ruleWrapper)) {
        Set<String> unmatchedSelectors=unmatchedRules.get(ruleWrapper);
        unmatchedSelectors.remove(matchedSelector);
        if (unmatchedSelectors.isEmpty()) {
          unmatchedRules.remove(ruleWrapper);
        }
      }
      return ruleWrapper.rule;
    }
  }
  return null;
}

@ Nullable public RuleType matchingRule ( ProtoElement elem ) { RuleType result = ruleMap . get ( elem ) ; if ( result != null ) { return result ; } for ( int i = rules . size ( ) - 1 ; i >= 0 ; i -- ) { RuleWrapper < RuleType > ruleWrapper = rules . get ( i ) ; String matchedSelector = ruleWrapper . getMatchedSelector ( elem ) ; if ( matchedSelector != null ) { ruleMap . put ( elem , ruleWrapper . rule ) ; if ( unmatchedRules . containsKey ( ruleWrapper ) ) { Set < String > unmatchedSelectors = unmatchedRules . get ( ruleWrapper ) ; unmatchedSelectors . remove ( matchedSelector ) ; if ( unmatchedSelectors . isEmpty ( ) ) { unmatchedRules . remove ( ruleWrapper ) ; } } return ruleWrapper . rule ; } } return null ; }
returns the matching rule for the element , or null , if no matching exists .
