/** * 打印出StoreMap的数据 */ public static void printStoreMap(Reflections reflections) { LOGGER.info("Now we will print store map......"); Store store = reflections.getStore(); Map<String/* indexName */, Multimap<String, String>> storeMap = store.getStoreMap(); for (String indexName : storeMap.keySet()) { LOGGER.info("===================================="); LOGGER.info("indexName:" + indexName); Multimap<String, String> multimap = storeMap.get(indexName); for (String firstName : multimap.keySet()) { Collection<String> lastNames = multimap.get(firstName); LOGGER.info("\t\t" + firstName + ": " + lastNames); } } }
private Document createDocument(final Reflections reflections) { Store map = reflections.getStore(); Document document = DocumentFactory.getInstance().createDocument(); Element root = document.addElement("Reflections"); for (String indexName : map.keySet()) { Element indexElement = root.addElement(indexName); for (String key : map.get(indexName).keySet()) { Element entryElement = indexElement.addElement("entry"); entryElement.addElement("key").setText(key); Element valuesElement = entryElement.addElement("values"); for (String value : map.get(indexName).get(key)) { valuesElement.addElement("value").setText(value); } } } return document; }
public static void printAll(ClassLoader classLoader) { Reflections reflections = new Reflections("com.magnet.mmx.protocol"); // iterate through all and print the JSON schema Store store = reflections.getStore(); Map<String, Multimap<String, String>> map = store.getStoreMap(); Set<String> entrySet = map.keySet(); for (String key: entrySet) { Multimap<String, String> entries = map.get(key); if ("SubTypesScanner".equalsIgnoreCase(key)) { for (String key2: entries.keySet()) { // get the class and find its sub-types try { if (schemaHashMap.containsKey(key2)) { continue; } Class<?> clazz = classLoader.loadClass(key2); Set<? extends Class<?>> subTypes = reflections.getSubTypesOf(clazz); for (Class subType: subTypes) { if (schemaHashMap.containsKey(subType.getName())) { continue; } System.out.println(); PojoSchema schema = getJsonSchemaFormat(subType); printSchema(schema); schemaHashMap.put(subType.getName(), schema); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } } System.out.println(); } }
private static Collection<String> getGwtTestCaseClassNames(final Reflections reflections) { Store store = reflections.getStore(); Multimap<String, String> multimap = store.get(GwtTestCaseScanner.class); return multimap.values(); }