/** * Perform a partition-by-predicate operation. * Each value in the input is tested by the predicate and * added to either the falseValues list or the trueValues list. * @param collection The input collection. * @param predicate A test for selecting the target list. * @return Two lists bundled in an object. **/ public static <V> PredicateSplit<V> partition(Iterable<V> collection, Predicate<? super V> predicate) { PredicateSplit<V> r = new PredicateSplit<V>(); for (V value : collection) { if (predicate.test(value)) { r.trueValues.add(value); } else { r.falseValues.add(value); } } return r; } }
/** * @return the number of bundles installed by this call. */ private int install(List<FileReference> references) { Set<FileReference> bundlesToInstall = new HashSet<>(references); bundlesToInstall.removeAll(reference2Bundles.keySet()); PredicateSplit<FileReference> bundlesToInstall_isDisk = partition(bundlesToInstall, BundleLoader::isDiskBundle); installBundlesFromDisk(bundlesToInstall_isDisk.trueValues); installBundlesFromFileDistribution(bundlesToInstall_isDisk.falseValues); startBundles(); return bundlesToInstall.size(); }