private List<String> getCategories(final Class<?> a) { final Category c = a.getAnnotation(Category.class); return FCollection.flatMap(Arrays.asList(c), toCategoryNames()); }
private Collection<File> collectDirectories(final File root, final int depth) { final Collection<File> childDirs = listFirstLevelDirectories(root); if (depth < MAX_DEPTH) { childDirs.addAll(FCollection.flatMap(childDirs, collectChildren(depth + 1))); } return childDirs; }
private List<String> findModifiedClassNames() throws MojoExecutionException { final File sourceRoot = new File(this.project.getBuild() .getSourceDirectory()); final List<String> modifiedPaths = FCollection.map(findModifiedPaths(), pathByScmDir()); return FCollection.flatMap(modifiedPaths, new PathToJavaClassConverter( sourceRoot.getAbsolutePath())); }
public SmartSourceLocator(final Collection<File> roots) { final Collection<File> childDirs = FCollection.flatMap(roots, collectChildren(0)); childDirs.addAll(roots); final Function<File, SourceLocator> fileToSourceLocator = a -> new DirectorySourceLocator(a); this.children = FCollection.map(childDirs, fileToSourceLocator); }
@Test public void shouldApplyFlatMapToAllItems() { final Function<Integer, Collection<Integer>> f = a -> Arrays.asList(a, a); final Collection<Integer> expected = Arrays.asList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5); assertEquals(expected, FCollection.flatMap(this.is, f)); }
private MutationResultListener createResultListener(final MutationMetaData mutationMetaData) throws ReportAggregationException { final SourceLocator sourceLocator = new SmartSourceLocator(this.sourceCodeDirectories); final CodeSource codeSource = this.codeSourceAggregator.createCodeSource(); final CoverageDatabase coverageDatabase = calculateCoverage(codeSource, mutationMetaData); final Collection<String> mutatorNames = new HashSet<>(FCollection.flatMap(mutationMetaData.getMutations(), resultToMutatorName())); return new MutationHtmlReportListener(coverageDatabase, this.resultOutputStrategy, mutatorNames, sourceLocator); }
public List<MutationAnalysisUnit> createMutationTestUnits( final Collection<ClassName> codeClasses) { final List<MutationAnalysisUnit> tus = new ArrayList<>(); final List<MutationDetails> mutations = FCollection.flatMap(codeClasses, classToMutations()); Collections.sort(mutations, comparator()); final Collection<MutationResult> analysedMutations = this.analyser .analyse(mutations); final Collection<MutationDetails> needAnalysis = analysedMutations.stream() .filter(statusNotKnown()) .map(resultToDetails()) .collect(Collectors.toList()); final List<MutationResult> analysed = FCollection.filter(analysedMutations, Prelude.not(statusNotKnown())); if (!analysed.isEmpty()) { tus.add(makePreAnalysedUnit(analysed)); } if (!needAnalysis.isEmpty()) { for (final Collection<MutationDetails> ms : this.grouper.groupMutations( codeClasses, needAnalysis)) { tus.add(makeUnanalysedUnit(ms)); } } Collections.sort(tus, new AnalysisPriorityComparator()); return tus; }
@Test public void flatMapShouldTreatNullAsEmptyIterable() { assertEquals(Collections.emptyList(), FCollection.flatMap(null, objectToObjectIterable())); }
private List<String> getCategories(final Class<?> a) { final Category c = a.getAnnotation(Category.class); return FCollection.flatMap(Arrays.asList(c), toCategoryNames()); }
private List<String> findModifiedClassNames() throws MojoExecutionException { final File sourceRoot = new File(this.project.getBuild() .getSourceDirectory()); final List<String> modifiedPaths = FCollection.map(findModifiedPaths(), pathByScmDir()); return FCollection.flatMap(modifiedPaths, new PathToJavaClassConverter( sourceRoot.getAbsolutePath())); }