DocumentationProvider (Collection<? extends DocumentationProvider> providers) { List<DocumentationProvider> list = new ArrayList<>(); for (DocumentationProvider provider : providers) { if (provider instanceof CompositeDocumentationProvider) { list.addAll(((CompositeDocumentationProvider)provider).getProviders()); } else if (provider != null) { list.add(provider); } } // CompositeDocumentationProvider should be returned anyway because it // handles DocumentationProvider.EP as well as providers from the list return new CompositeDocumentationProvider(Collections.unmodifiableList(list)); }