/** {@inheritDoc} */ @Override public <T extends Extension> void registerExtension(Class<T> extensionItf, T extensionImpl) { List<Object> list = extensionsCollector.get(extensionItf); if (list == null) { list = new ArrayList<>(); extensionsCollector.put(extensionItf, list); } list.add(extensionImpl); }
/** @return Map extension interface to array of implementation. */ public Map<Class<?>, Object[]> createExtensionMap() { Map<Class<?>, Object[]> extensions = new HashMap<>(extensionsCollector.size() * 2, 0.5f); for (Map.Entry<Class<?>, List<Object>> entry : extensionsCollector.entrySet()) { Class<?> extensionItf = entry.getKey(); List<Object> implementations = entry.getValue(); Object[] implArr = (Object[]) Array.newInstance(extensionItf, implementations.size()); implArr = implementations.toArray(implArr); extensions.put(extensionItf, implArr); } return extensions; }