CndExporter { static <T, E extends Throwable> void combineCauseMessages(final @NotNull Stream<Result<T>> results, final @NotNull Class<? extends Throwable> causeType, final @NotNull Class<E> andThrow) throws E { final String combined = results.filter(Result::isFailure) .map(result -> result.findCause(causeType)) .filter(Optional::isPresent) .map(Optional::get) .map(Throwable::getMessage) .collect(Collectors.joining(", ")); if (!combined.isEmpty()) { E rethrow; try { rethrow = andThrow.getConstructor(String.class).newInstance(combined); } catch (final ReflectiveOperationException e) { throw new IllegalStateException(combined, e); } throw rethrow; } } private  CndExporter(final List<Rule> scopeExportNames,
                        final List<Rule> scopeReplaceNames,
                        final boolean includeBuiltins); void writeNodetypes(final @NotNull File cndFile,
                               final @NotNull Session session,
                               final @NotNull List<String> desiredTypeNames); void writeNodetypes(final @NotNull WriterOpener writerOpener,
                               final @NotNull Session session,
                               final @NotNull List<String> desiredTypeNames,
                               final @Nullable File initialCnd); static Map<Name, NodeTypeDefinition> retrieveNodeTypes(final @NotNull Session session,
                                                                  final @NotNull Collection<Name> desiredTypeNames); static Map<Name, NodeTypeDefinition> retrieveNodeTypes(final @NotNull Session session,
                      final @NotNull Collection<Name> desiredTypeNames,
                      final @Nullable BiPredicate<NamePathResolver, NodeType> nodeTypeSelector); static final List<String> BUILTIN_NODETYPES; }
@Test(expected = IllegalStateException.class) public void testCombineCauseMessages_reflectiveError() throws NoStringConstructorException { CndExporter.combineCauseMessages( Stream.of( Result.failure(new Exception("one")), Result.failure(new Exception("two"))), Exception.class, NoStringConstructorException.class); }