public static Map < Long , Message > findMessages ( final Document document , final XPath xPath , final Map < String , Type > typeByNameMap ) throws Exception { final Map < Long , Message > messageByIdMap = new HashMap <> ( ) ; final ObjectHashSet < String > distinctNames = new ObjectHashSet <> ( ) ; forEach ( ( NodeList ) xPath . compile ( MESSAGE_XPATH_EXPR ) . evaluate ( document , XPathConstants . NODESET ) , ( node ) - > addMessageWithIdCheck ( distinctNames , messageByIdMap , new Message ( node , typeByNameMap ) , node ) ) ; return messageByIdMap ; }
Scan XML for all message definitions and save in map