Java Code Examples for org.apache.commons.collections4.IterableUtils#forEach()
The following examples show how to use
org.apache.commons.collections4.IterableUtils#forEach() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuildAssignmentService.java From gocd with Apache License 2.0 | 6 votes |
protected EntityConfigChangedListener<PipelineConfig> pipelineConfigChangedListener() { return new EntityConfigChangedListener<PipelineConfig>() { @Override public void onEntityConfigChange(PipelineConfig pipelineConfig) { LOGGER.info("[Configuration Changed] Removing deleted jobs for pipeline {}.", pipelineConfig.name()); synchronized (BuildAssignmentService.this) { List<JobPlan> jobsToRemove; if (goConfigService.hasPipelineNamed(pipelineConfig.name())) { jobsToRemove = getMismatchingJobPlansFromUpdatedPipeline(pipelineConfig, jobPlans); } else { jobsToRemove = getAllJobPlansFromDeletedPipeline(pipelineConfig, jobPlans); } IterableUtils.forEach(jobsToRemove, o -> removeJob(o)); } } }; }
Example 2
Source File: ChannelGraphNavigationTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 5 votes |
@Before public void setUp() { mainActivity = RobolectricUtil.INSTANCE.getActivity(); scanner = MainContextHelper.INSTANCE.getScannerService(); settings = MainContextHelper.INSTANCE.getSettings(); configuration = MainContextHelper.INSTANCE.getConfiguration(); layout = mock(View.class); views = new HashMap<>(); IterableUtils.forEach(ChannelGraphNavigation.ids.keySet(), new PairSetUpClosure()); fixture = new ChannelGraphNavigation(layout, mainActivity); }
Example 3
Source File: SeriesCacheTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 5 votes |
@Test public void testRemoveExpectNoneLeft() { // setup List<WiFiDetail> expected = withData(); // execute List<BaseSeries<DataPoint>> actual = fixture.remove(expected); // validate assertEquals(expected.size(), actual.size()); IterableUtils.forEach(expected, new ContainsFalseClosure()); }
Example 4
Source File: WiFiBandAdapterTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 5 votes |
@Test public void testRemovingAllWillNotRemoveLast() { // setup Set<WiFiBand> values = EnumUtils.values(WiFiBand.class); // execute IterableUtils.forEach(values, new ToggleClosure()); // validate IterableUtils.forEachButLast(values, new RemovedClosure()); assertTrue(fixture.contains(IterableUtils.get(values, values.size() - 1))); }
Example 5
Source File: RepositoryScannerInstance.java From archiva with Apache License 2.0 | 5 votes |
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { final Path relativeFile = basePath.relativize( file ); if (excludeMatcher.stream().noneMatch(m -> m.matches(relativeFile)) && includeMatcher.stream().allMatch(m -> m.matches(relativeFile))) { log.debug( "Walk Step: {}, {}", file ); stats.increaseFileCount(); // consume files regardless - the predicate will check the timestamp Path repoPath = PathUtil.getPathFromUri( repository.getLocation() ); BaseFile basefile = new BaseFile( repoPath.toString(), file.toFile() ); // Timestamp finished points to the last successful scan, not this current one. if ( Files.getLastModifiedTime(file).toMillis() >= changesSince ) { stats.increaseNewFileCount(); } consumerProcessFile.setBasefile( basefile ); consumerWantsFile.setBasefile( basefile ); Closure<RepositoryContentConsumer> processIfWanted = IfClosure.ifClosure( consumerWantsFile, consumerProcessFile ); IterableUtils.forEach( this.knownConsumers, processIfWanted ); if ( consumerWantsFile.getWantedFileCount() <= 0 ) { // Nothing known processed this file. It is invalid! IterableUtils.forEach( this.invalidConsumers, consumerProcessFile ); } } return FileVisitResult.CONTINUE; }
Example 6
Source File: RepositoryScannerInstance.java From archiva with Apache License 2.0 | 5 votes |
public RepositoryScannerInstance( ManagedRepository repository, List<KnownRepositoryContentConsumer> knownConsumerList, List<InvalidRepositoryContentConsumer> invalidConsumerList ) { this.repository = repository; this.knownConsumers = knownConsumerList; this.invalidConsumers = invalidConsumerList; addFileNameIncludePattern("**/*"); consumerTimings = new HashMap<>(); consumerCounts = new HashMap<>(); this.consumerProcessFile = new ConsumerProcessFileClosure(); consumerProcessFile.setExecuteOnEntireRepo( true ); consumerProcessFile.setConsumerTimings( consumerTimings ); consumerProcessFile.setConsumerCounts( consumerCounts ); this.consumerWantsFile = new ConsumerWantsFilePredicate( repository ); stats = new RepositoryScanStatistics(); stats.setRepositoryId( repository.getId() ); Closure<RepositoryContentConsumer> triggerBeginScan = new TriggerBeginScanClosure( repository, new Date( System.currentTimeMillis() ), true ); IterableUtils.forEach( knownConsumerList, triggerBeginScan ); IterableUtils.forEach( invalidConsumerList, triggerBeginScan ); if ( SystemUtils.IS_OS_WINDOWS ) { consumerWantsFile.setCaseSensitive( false ); } }
Example 7
Source File: TimeGraphCacheTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 5 votes |
private List<WiFiDetail> withWiFiDetails() { List<WiFiDetail> results = new ArrayList<>(); for (int i = 0; i < 4; i++) { WiFiDetail wiFiDetail = withWiFiDetail("SSID" + i); results.add(wiFiDetail); } IterableUtils.forEach(results, new AddClosure()); for (int i = 0; i < GraphConstants.MAX_NOTSEEN_COUNT; i++) { fixture.add(results.get(0)); } return results; }
Example 8
Source File: StrengthFilterTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Test public void testMapping() { Set<Strength> strengths = EnumUtils.values(Strength.class); assertEquals(strengths.size(), StrengthFilter.ids.size()); IterableUtils.forEach(strengths, new MappingClosure()); }
Example 9
Source File: WiFiChannelCountryGHZ2Test.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Test public void testChannelsForUSAndSimilar() { List<String> countries = Arrays.asList("AS", "CA", "CO", "DO", "FM", "GT", "GU", "MP", "MX", "PA", "PR", "UM", "US", "UZ", "VI"); IterableUtils.forEach(countries, new ChannelUSClosure()); }
Example 10
Source File: NavigationMenuController.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Override public void execute(final NavigationGroup navigationGroup) { IterableUtils.forEach(navigationGroup.getNavigationMenus(), new NavigationItemClosure(menu, navigationGroup)); }
Example 11
Source File: EnumUtilsTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
private void validate(Collection<TestObject> expected, Collection<TestObject> actual) { assertEquals(expected.size(), actual.size()); IterableUtils.forEach(expected, new TestObjectClosure(actual)); }
Example 12
Source File: WiFiDataTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
private void verifyVendorNames() { IterableUtils.forEach(wiFiDetails, new VerifyVendorNameClosure()); }
Example 13
Source File: WiFiDataTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
private void withVendorNames() { IterableUtils.forEach(wiFiDetails, new VendorNameClosure()); }
Example 14
Source File: WiFiChannels.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@NonNull public List<WiFiChannel> getWiFiChannels() { List<WiFiChannel> results = new ArrayList<>(); IterableUtils.forEach(wiFiChannelPairs, new WiFiChannelClosure(results)); return results; }
Example 15
Source File: WiFiChannelCountryGHZ5Test.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Test public void testChannelsChinaSouthKorea() { int expectedSize = CHANNELS_SET1.size() + CHANNELS_SET3.size(); List<String> countries = Arrays.asList("CN", "KR"); IterableUtils.forEach(countries, new ChannelChinaClosure(expectedSize)); }
Example 16
Source File: SSIDAdapterTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Test public void testGetValue() { assertEquals(SSID_VALUES.size(), fixture.getValues().size()); IterableUtils.forEach(SSID_VALUES, new ContainsClosure()); }
Example 17
Source File: RepositoryContentConsumers.java From archiva with Apache License 2.0 | 4 votes |
/** * A convienence method to execute all of the active selected consumers for a * particular arbitrary file. * NOTE: Make sure that there is no repository scanning task executing before invoking this so as to prevent * the index writer/reader of the current index-content consumer executing from getting closed. For an example, * see ArchivaDavResource#executeConsumers( File ). * @param repository the repository configuration to use. * @param localFile the local file to execute the consumers against. * @param updateRelatedArtifacts TODO */ public void executeConsumers( ManagedRepository repository, Path localFile, boolean updateRelatedArtifacts ) throws ConsumerException { List<KnownRepositoryContentConsumer> selectedKnownConsumers = null; // Run the repository consumers try { Closure<RepositoryContentConsumer> triggerBeginScan = new TriggerBeginScanClosure( repository, getStartTime(), false ); selectedKnownConsumers = getSelectedKnownConsumers(); // MRM-1212/MRM-1197 // - do not create missing/fix invalid checksums and update metadata when deploying from webdav since these are uploaded by maven if ( !updateRelatedArtifacts ) { List<KnownRepositoryContentConsumer> clone = new ArrayList<>(); clone.addAll( selectedKnownConsumers ); for ( KnownRepositoryContentConsumer consumer : clone ) { if ( consumer.getId().equals( "create-missing-checksums" ) || consumer.getId().equals( "metadata-updater" ) ) { selectedKnownConsumers.remove( consumer ); } } } List<InvalidRepositoryContentConsumer> selectedInvalidConsumers = getSelectedInvalidConsumers(); IterableUtils.forEach( selectedKnownConsumers, triggerBeginScan ); IterableUtils.forEach( selectedInvalidConsumers, triggerBeginScan ); // yuck. In case you can't read this, it says // "process the file if the consumer has it in the includes list, and not in the excludes list" Path repoPath = PathUtil.getPathFromUri( repository.getLocation() ); BaseFile baseFile = new BaseFile( repoPath.toString(), localFile.toFile() ); ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate( repository ); predicate.setBasefile( baseFile ); predicate.setCaseSensitive( false ); ConsumerProcessFileClosure closure = new ConsumerProcessFileClosure(); closure.setBasefile( baseFile ); closure.setExecuteOnEntireRepo( false ); Closure<RepositoryContentConsumer> processIfWanted = IfClosure.ifClosure( predicate, closure ); IterableUtils.forEach( selectedKnownConsumers, processIfWanted ); if ( predicate.getWantedFileCount() <= 0 ) { // Nothing known processed this file. It is invalid! IterableUtils.forEach( selectedInvalidConsumers, closure ); } TriggerScanCompletedClosure scanCompletedClosure = new TriggerScanCompletedClosure( repository, false ); IterableUtils.forEach( selectedKnownConsumers, scanCompletedClosure ); } finally { /* TODO: This is never called by the repository scanner instance, so not calling here either - but it probably should be? IterableUtils.forEach( availableKnownConsumers, triggerCompleteScan ); IterableUtils.forEach( availableInvalidConsumers, triggerCompleteScan ); */ releaseSelectedKnownConsumers( selectedKnownConsumers ); } }
Example 18
Source File: SecurityAdapterTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Test public void testContains() { IterableUtils.forEach(EnumUtils.values(Security.class), new ContainsClosure()); }
Example 19
Source File: WiFiBandAdapterTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Test public void testContains() { IterableUtils.forEach(EnumUtils.values(WiFiBand.class), new ContainsClosure()); }
Example 20
Source File: ChannelGraphAdapter.java From WiFiAnalyzer with GNU General Public License v3.0 | 4 votes |
@Override public void execute(WiFiBand wiFiBand) { IterableUtils.forEach(wiFiBand.getWiFiChannels().getWiFiChannelPairs(), new WiFiChannelClosure(graphViewNotifiers, wiFiBand)); }