@Test public void testAddDefinitionsAsPatternMatchers() { DefinitionPatternMatcherFactory factory = createMock(DefinitionPatternMatcherFactory.class); PatternRecognizer recognizer = createMock(PatternRecognizer.class); DefinitionPatternMatcher firstMatcher = createMock(DefinitionPatternMatcher.class); DefinitionPatternMatcher thirdMatcher = createMock(DefinitionPatternMatcher.class); expect(recognizer.isPatternRecognized("first")).andReturn(true); expect(recognizer.isPatternRecognized("second")).andReturn(false); expect(recognizer.isPatternRecognized("third")).andReturn(true); Definition firstDefinition = new Definition("first", (Attribute) null, null); Definition secondDefinition = new Definition("second", (Attribute) null, null); Definition thirdDefinition = new Definition("third", (Attribute) null, null); expect(factory.createDefinitionPatternMatcher("first", firstDefinition)) .andReturn(firstMatcher); expect(factory.createDefinitionPatternMatcher("third", thirdDefinition)) .andReturn(thirdMatcher); replay(factory, recognizer, firstMatcher, thirdMatcher); BasicPatternDefinitionResolver<Integer> resolver = new BasicPatternDefinitionResolver<Integer>( factory, recognizer); Map<String, Definition> localeDefsMap = new LinkedHashMap<String, Definition>(); localeDefsMap.put("first", firstDefinition); localeDefsMap.put("second", secondDefinition); localeDefsMap.put("third", thirdDefinition); List<DefinitionPatternMatcher> matchers = new ArrayList<DefinitionPatternMatcher>(); resolver.addDefinitionsAsPatternMatchers(matchers, localeDefsMap); assertEquals(2, matchers.size()); assertEquals(firstMatcher, matchers.get(0)); assertEquals(thirdMatcher, matchers.get(1)); verify(factory, recognizer, firstMatcher, thirdMatcher); }
@Override protected Map<String, Definition> addDefinitionsAsPatternMatchers(List<DefinitionPatternMatcher> matchers, Map<String, Definition> defsMap) { Set<String> excludedKeys = new LinkedHashSet<String>(); for (Map.Entry<String, Definition> de : defsMap.entrySet()) { String key = de.getKey(); if (patternRecognizer.isPatternRecognized(key)) { matchers.add(definitionPatternMatcherFactory .createDefinitionPatternMatcher(key, de.getValue())); } else { excludedKeys.add(key); } } return PatternUtil.createExtractedMap(defsMap, excludedKeys); }
BasicPatternDefinitionResolver extends
        AbstractPatternDefinitionResolver<T> { @Override protected Map<String, Definition> addDefinitionsAsPatternMatchers(List<DefinitionPatternMatcher> matchers, Map<String, Definition> defsMap) { Set<String> excludedKeys = new LinkedHashSet<String>(); for (Map.Entry<String, Definition> de : defsMap.entrySet()) { String key = de.getKey(); if (patternRecognizer.isPatternRecognized(key)) { matchers.add(definitionPatternMatcherFactory .createDefinitionPatternMatcher(key, de.getValue())); } else { excludedKeys.add(key); } } return PatternUtil.createExtractedMap(defsMap, excludedKeys); } }
BasicPatternDefinitionResolver extends
        AbstractPatternDefinitionResolver<T> { @Override protected Map<String, Definition> addDefinitionsAsPatternMatchers(List<DefinitionPatternMatcher> matchers, Map<String, Definition> defsMap) { Set<String> excludedKeys = new LinkedHashSet<String>(); for (Map.Entry<String, Definition> de : defsMap.entrySet()) { String key = de.getKey(); if (patternRecognizer.isPatternRecognized(key)) { matchers.add(definitionPatternMatcherFactory .createDefinitionPatternMatcher(key, de.getValue())); } else { excludedKeys.add(key); } } return PatternUtil.createExtractedMap(defsMap, excludedKeys); } BasicPatternDefinitionResolver(DefinitionPatternMatcherFactory definitionPatternMatcherFactory,
            PatternRecognizer patternRecognizer); }
BasicPatternDefinitionResolver extends
        AbstractPatternDefinitionResolver<T> { @Override protected Map<String, Definition> addDefinitionsAsPatternMatchers(List<DefinitionPatternMatcher> matchers, Map<String, Definition> defsMap) { Set<String> excludedKeys = new LinkedHashSet<String>(); for (Map.Entry<String, Definition> de : defsMap.entrySet()) { String key = de.getKey(); if (patternRecognizer.isPatternRecognized(key)) { matchers.add(definitionPatternMatcherFactory .createDefinitionPatternMatcher(key, de.getValue())); } else { excludedKeys.add(key); } } return PatternUtil.createExtractedMap(defsMap, excludedKeys); } BasicPatternDefinitionResolver(DefinitionPatternMatcherFactory definitionPatternMatcherFactory,
            PatternRecognizer patternRecognizer);  }
BasicPatternDefinitionResolver extends
        AbstractPatternDefinitionResolver<T> { @Override protected Map<String, Definition> addDefinitionsAsPatternMatchers(List<DefinitionPatternMatcher> matchers, Map<String, Definition> defsMap) { Set<String> excludedKeys = new LinkedHashSet<String>(); for (Map.Entry<String, Definition> de : defsMap.entrySet()) { String key = de.getKey(); if (patternRecognizer.isPatternRecognized(key)) { matchers.add(definitionPatternMatcherFactory .createDefinitionPatternMatcher(key, de.getValue())); } else { excludedKeys.add(key); } } return PatternUtil.createExtractedMap(defsMap, excludedKeys); } BasicPatternDefinitionResolver(DefinitionPatternMatcherFactory definitionPatternMatcherFactory,
            PatternRecognizer patternRecognizer);   }