forEach ( )源码实例Demo

java.util.List#forEach ( )源码实例Demo

下面列出了java.util.List#forEach ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@DeleteMapping
public void deleteByIds(@RequestParam(name = "ids") final String notificationIdsListStr)
{
	userSession.assertLoggedIn();

	final UserId adUserId = userSession.getLoggedUserId();

	final List<String> notificationIds = Splitter.on(",")
			.trimResults()
			.omitEmptyStrings()
			.splitToList(notificationIdsListStr);
	if (notificationIds.isEmpty())
	{
		throw new AdempiereException("No IDs provided");
	}

	notificationIds.forEach(notificationId -> userNotificationsService.deleteNotification(adUserId, notificationId));
}
 
源代码2 项目: meghanada-server   文件: EmacsServer.java
private void accept() throws IOException {
  List<Future<?>> futures = new ArrayList<>(2);
  while (!this.serverSocket.isClosed()) {
    final Socket conn = this.serverSocket.accept();
    log.info("client connected");
    conn.setKeepAlive(true);
    final Future<?> future = acceptConnection(conn);
    futures.add(future);
  }

  futures.forEach(
      (future) -> {
        try {
          future.get();
        } catch (InterruptedException | ExecutionException e) {
          log.catching(e);
        }
      });
}
 
@Test
public void testMixed(@DockerBrowser(type = CHROME) RemoteWebDriver chrome,
        @DockerBrowser(type = CHROME, size = NUM_BROWSERS) List<RemoteWebDriver> driverList,
        @DockerBrowser(type = FIREFOX) RemoteWebDriver firefox)
        throws InterruptedException {

    ExecutorService executorService = newFixedThreadPool(NUM_BROWSERS + 2);
    CountDownLatch latch = new CountDownLatch(NUM_BROWSERS + 2);

    driverList.forEach((driver) -> {
        exercise(executorService, latch, driver);
    });
    exercise(executorService, latch, chrome);
    exercise(executorService, latch, firefox);

    latch.await(50, SECONDS);

    // Thread.sleep(30000);

    executorService.shutdown();
}
 
源代码4 项目: fastquery   文件: PropertiesUtil.java
private static void check(List<String> dataSourceNames, List<String> bpNames) {
	// 1. dataSourceNames 不能重复
	for (int i = 0; i < dataSourceNames.size(); i++) {
		if (Collections.frequency(dataSourceNames, dataSourceNames.get(i)) > 1) {
			throw new RepositoryException("fastquery.json 配置文件中 \"dataSourceName\"=\"" + dataSourceNames.get(i) + "\" 不能重复出现.");
		}
	}
	
	// 2. bpNames 不能重复
	for (int j = 0; j < bpNames.size(); j++) {
		if (Collections.frequency(bpNames, bpNames.get(j)) > 1) {
			throw new RepositoryException("fastquery.json 配置文件中, basePackages中的元素\"" + bpNames.get(j) + "\"不能重复出现.");
		}
	}
	
	// 3. 不能出现诸如: org.fastquery.db(包地址) 又配置了它的子类org.fastquery.db.AA
	bpNames.forEach(b1 -> bpNames.forEach(b2 -> {
		if (b2.startsWith(b1 + '.')) {
			throw new RepositoryException("basePackages配置错误: " + b1 + " 已经包含了" + b2 + " 两者只能选一");
		}
	}));
}
 
源代码5 项目: tinkerpop   文件: MatchStepTest.java
@Test
public void testPreCompilationOfWherePredicate() {
    final List<Traversal.Admin<?, ?>> traversals = Arrays.asList(
            __.match(as("a").out().as("b"), as("c").where(P.neq("d"))).asAdmin(),
            __.match(as("a").out().as("b"), where("c", P.neq("d"))).asAdmin());
    assertEquals(1, new HashSet<>(traversals).size()); // the two patterns should pre-compile to the same traversal
    traversals.forEach(traversal -> {
        final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
        //assertFalse(matchStep.getStartLabel().isPresent());
        assertEquals(2, matchStep.getGlobalChildren().size());
        Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
        assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
        assertEquals(VertexStep.class, pattern.getStartStep().getNextStep().getClass());
        assertEquals("b", ((MatchStep.MatchEndStep) pattern.getEndStep()).getMatchKey().get());
        //
        pattern = matchStep.getGlobalChildren().get(1);
        assertEquals(MatchStep.MatchStartStep.class, pattern.getStartStep().getClass());
        assertEquals("c", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
        assertEquals(WherePredicateStep.class, pattern.getStartStep().getNextStep().getClass());
        assertEquals(MatchStep.MatchEndStep.class, pattern.getStartStep().getNextStep().getNextStep().getClass());
        assertFalse(((WherePredicateStep<?>) pattern.getStartStep().getNextStep()).getStartKey().isPresent());
        assertEquals("d", ((WherePredicateStep<?>) pattern.getStartStep().getNextStep()).getPredicate().get().getOriginalValue());
    });
}
 
源代码6 项目: james-project   文件: ElasticSearchIndexer.java
public Mono<BulkResponse> update(List<UpdatedRepresentation> updatedDocumentParts, RoutingKey routingKey) {
    Preconditions.checkNotNull(updatedDocumentParts);
    Preconditions.checkNotNull(routingKey);
    BulkRequest request = new BulkRequest();
    updatedDocumentParts.forEach(updatedDocumentPart -> request.add(
        new UpdateRequest(aliasName.getValue(),
            NodeMappingFactory.DEFAULT_MAPPING_NAME,
            updatedDocumentPart.getId().asString())
            .doc(updatedDocumentPart.getUpdatedDocumentPart(), XContentType.JSON)
            .routing(routingKey.asString())));

    return client.bulk(request, RequestOptions.DEFAULT)
        .onErrorResume(ValidationException.class, exception -> {
            LOGGER.warn("Error while updating index", exception);
            return Mono.empty();
        });
}
 
源代码7 项目: nomulus   文件: DeleteContactsAndHostsAction.java
/**
 * Deletes a list of tasks associated with deletion requests from the async delete queue using a
 * retrier.
 */
private void deleteStaleTasksWithRetry(final List<DeletionRequest> deletionRequests) {
  if (deletionRequests.isEmpty()) {
    return;
  }
  final List<TaskHandle> tasks =
      deletionRequests.stream().map(DeletionRequest::task).collect(toImmutableList());
  retrier.callWithRetry(() -> queue.deleteTask(tasks), TransientFailureException.class);
  deletionRequests.forEach(
      deletionRequest ->
          asyncTaskMetrics.recordAsyncFlowResult(
              deletionRequest.getMetricOperationType(),
              OperationResult.STALE,
              deletionRequest.requestedTime()));
}
 
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMosaicsFromAccount(RepositoryType type) {
    List<MosaicInfo> mosaicInfos = get(getMosaicRepository(type)
        .search(new MosaicSearchCriteria().ownerAddress(testAccount.getAddress()))).getData();
    Assertions.assertTrue(mosaicInfos.size() > 0);
    mosaicInfos.forEach(this::assertMosaic);
    Assertions.assertTrue(
        mosaicInfos.stream().anyMatch(mosaicInfo -> mosaicInfo.getMosaicId().equals(mosaicId)));
}
 
源代码9 项目: hmily   文件: MongoCompensationServiceImpl.java
@Override
public Boolean batchRemove(final List<String> ids, final String applicationName) {
    if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(applicationName)) {
        return Boolean.FALSE;
    }
    final String mongoTableName = RepositoryPathUtils.buildMongoTableName(applicationName);
    ids.forEach(id -> {
        Query query = new Query();
        query.addCriteria(new Criteria("transId").is(id));
        mongoTemplate.remove(query, mongoTableName);
    });
    return Boolean.TRUE;
}
 
源代码10 项目: joyrpc   文件: ProviderBean.java
public void setParams(List<ParameterConfig> params) {
    this.params = params;
    if (params != null) {
        params.forEach(param -> {
            if (param != null
                    && io.joyrpc.util.StringUtils.isNotEmpty(param.getKey())
                    && io.joyrpc.util.StringUtils.isNotEmpty(param.getValue())) {
                String key = param.isHide() && !param.getKey().startsWith(".") ? "." + param.getKey() : param.getKey();
                setParameter(key, param.getValue());
            }
        });
    }
}
 
源代码11 项目: freeacs   文件: ResetUtil.java
public static void resetReboot(SessionDataI sessionData) {
  log.debug("The reboot parameter is reset to 0 and the reboot will be executed");
  Unittype unittype = sessionData.getUnittype();
  UnittypeParameter utp = unittype.getUnittypeParameters().getByName(SystemParameters.RESTART);
  List<UnitParameter> unitParameters = new ArrayList<>();
  UnitParameter up = new UnitParameter(utp, sessionData.getUnitId(), "0", sessionData.getProfile());
  unitParameters.add(up);
  unitParameters.forEach(sessionData.getUnit()::toWriteQueue);
}
 
源代码12 项目: grpc-swagger   文件: ServiceRegisterUtils.java
public static List<String> getServiceNames(List<DescriptorProtos.FileDescriptorSet> fileDescriptorSets) {
    List<String> serviceNames = new ArrayList<>();
    fileDescriptorSets.forEach(fileDescriptorSet -> {
        ServiceResolver serviceResolver = ServiceResolver.fromFileDescriptorSet(fileDescriptorSet);
        serviceResolver.listServices().forEach(serviceDescriptor -> {
            String serviceName = serviceDescriptor.getFullName();
            if (blockServiceSet.contains(serviceName.toLowerCase())) {
                return;
            }
            serviceNames.add(serviceName);
        });
    });
    return serviceNames;
}
 
@Test
public void testBulkOps() throws Exception {
  List<Cache<Long, String>> caches = new ArrayList<>();
  caches.add(cacheOne);
  caches.add(cacheTwo);

  Map<Long, String> entriesMap = new HashMap<>();
  entriesMap.put(1L, "one");
  entriesMap.put(2L, "two");
  entriesMap.put(3L, "three");
  entriesMap.put(4L, "four");
  entriesMap.put(5L, "five");
  entriesMap.put(6L, "six");
  caches.forEach(cache -> cache.putAll(entriesMap));

  CLUSTER.getClusterControl().waitForRunningPassivesInStandby();
  CLUSTER.getClusterControl().terminateActive();

  Set<Long> keySet = entriesMap.keySet();
  caches.forEach(cache -> {
    Map<Long, String> all = cache.getAll(keySet);
    assertThat(all.get(1L), is("one"));
    assertThat(all.get(2L), is("two"));
    assertThat(all.get(3L), is("three"));
    assertThat(all.get(4L), is("four"));
    assertThat(all.get(5L), is("five"));
    assertThat(all.get(6L), is("six"));
  });

}
 
源代码14 项目: attic-aurora   文件: VariableBatchStrategy.java
/**
 * Creates a variable active-limited strategy that applies an upper bound to all results.
 *
 * @param maxActiveGroups  List of Maximum group sizes. Each group size represents a step.
 * {@link #getNextGroup(Set, Set)}.
 */
public VariableBatchStrategy(
    Ordering<T> ordering,
    List<Integer> maxActiveGroups,
    boolean rollingForward) {

  this.ordering = Objects.requireNonNull(ordering);
  this.rollingForward = rollingForward;

  maxActiveGroups.forEach(x -> Preconditions.checkArgument(x > 0));

  this.groupSizes = ImmutableList.copyOf(maxActiveGroups);
  this.totalModInstanceCount = Optional.empty();
}
 
源代码15 项目: skywalking   文件: DataTable.java
public List<Long> sortedValues(Comparator<String> keyComparator) {
    final List<String> collect = data.keySet().stream().sorted(keyComparator).collect(Collectors.toList());
    List<Long> values = new ArrayList<>(collect.size());
    collect.forEach(key -> values.add(data.get(key)));
    return values;
}
 
源代码16 项目: beakerx   文件: GroovyReflectionCompletion.java
List<String> autocompleteFromObject(List<String> parts) {
		
		List<String> lowPriorityCompletions = Arrays.asList("class","metaClass");

		List<String> filteredCompletions = Arrays.asList("empty");
		
		List<String> iterableOnlyCompletions = Arrays.asList("join(");

	
	
		ArrayList<String> result = new ArrayList<String>();
		
		try {

			String bindingReference = parts.get(0);
			Matcher m = indexedAccessPattern.matcher(bindingReference);
			
			Object value;
			if(m.matches()) {
				List collValue = (List)binding.getVariable(m.group(1));
				value = collValue.get(Integer.parseInt(m.group(2)));
			}
			else
				value = binding.getVariable(bindingReference);

			int i = 1;
			for(; i<parts.size()-1; ++i) {
				String partExpr = parts.get(i);
				
				
				Matcher m2 = indexedAccessPattern.matcher(partExpr);
				if(m2.matches()) {
					value = PropertyUtils.getIndexedProperty(value, partExpr);
				}
				else {
					value = PropertyUtils.getSimpleProperty(value, partExpr);
				}
			
				if(value == null) {
					// We can't complete anything on it
					// TODO: we could complete on the static type one day
					return result;
				}
			}
			
			String completionToken = parts.size() > 1 ? parts.get(parts.size()-1) : "";
			
			List<String> properties = getObjectPropertyNames(value); 
			
			List<String> lowPri = new ArrayList<String>();
		
			properties.forEach((String key) -> {
				if(key.startsWith(completionToken)) {
					if(lowPriorityCompletions.contains(key)) {
						lowPri.add(key);
					}
					else {
						result.add(key);
					}
				}
			});
			
			if(value instanceof Map) {
				Map<String,?> mapValue = (Map<String,?>)value;
				mapValue.keySet().stream()
								 .filter(k -> k.startsWith(completionToken))
								 .forEach(k -> result.add(k));
			}
			
			if(value instanceof Iterable || value instanceof Map) {
				result.addAll(SUPPLEMENTARY_COLLECTION_COMPLETIONS);
				result.addAll(iterableOnlyCompletions);
			}
			
			if(value instanceof String) {
				result.addAll(STRING_COMPLETIONS);
			}
			
//			result.addAll(lowPri);
			
			result.removeIf(v -> !v.startsWith(completionToken));
				
			result.removeAll(filteredCompletions);
			
			// Finally, add method names
			result.addAll(getObjectMethodCompletions(value, completionToken));
	
		} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
			e.printStackTrace();
		}
		return result;
	}
 
源代码17 项目: courgette-jvm   文件: ExtentReportsBuilder.java
private void addOutputs(ExtentTest node, List<String> outputs) {
    outputs.forEach(output -> log(node, output));
}
 
源代码18 项目: jMetal   文件: ESPEA.java
@Override
protected List<S> replacement(List<S> population, List<S> offspringPopulation) {
  // population and archive are always in sync
  offspringPopulation.forEach(s -> archive.add(s));
  return archive.getSolutionList();
}
 
源代码19 项目: joyqueue   文件: ProduceManager.java
protected void onPutMessage(String topic, String app, int partitionGroup, long startTime, List<WriteRequest> writeRequests) {
    long now = SystemClock.now();
    writeRequests.forEach(writeRequest -> {
        brokerMonitor.onPutMessage(topic, app, partitionGroup, writeRequest.getPartition(), writeRequest.getBatchSize(), writeRequest.getBuffer().limit(), now - startTime);
    });
}
 
源代码20 项目: hadoop-ozone   文件: OmMultipartUploadListParts.java
public void addProtoPartList(List<PartInfo> partInfos) {
  partInfos.forEach(partInfo -> partInfoList.add(new OmPartInfo(
      partInfo.getPartNumber(), partInfo.getPartName(),
      partInfo.getModificationTime(), partInfo.getSize())));
}