当前位置: 首页>>代码示例>>Java>>正文


Java List.forEach方法代码示例

本文整理汇总了Java中java.util.List.forEach方法的典型用法代码示例。如果您正苦于以下问题:Java List.forEach方法的具体用法?Java List.forEach怎么用?Java List.forEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.List的用法示例。


在下文中一共展示了List.forEach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import java.util.List; //导入方法依赖的package包/类
public void run(List<String> suitePackages) {
	String jarPath = Paths.get(System.getProperty("user.dir") + "/mat.jar")
			.toString();

	List<String> availableTestCases = ClassUtils.getClassesNamesInPackage(
			jarPath, suitePackages);

	//TODO - sort test cases alphabetically 
	availableTestCases.forEach(
			c -> {
				final String[] items = c.split("\\.");
				if (items.length>1){
					System.out.println(items[items.length-1]);
				}
			});
}
 
开发者ID:danrusu,项目名称:mobileAutomation,代码行数:17,代码来源:TestCaseDocs.java

示例2: loadExpressionOutputFieldToMappingSheetRow

import java.util.List; //导入方法依赖的package包/类
private void loadExpressionOutputFieldToMappingSheetRow(List<FilterProperties> outputList, ExpressionOutputFields expressionOutputFields,
		List<FilterProperties> combinedOutputList, List<GridRow> mappingSheetRowSchemaFields) {
	mappingSheetRowSchemaFields.clear();
	if(expressionOutputFields!=null && expressionOutputFields.getField()!=null){
			FilterProperties filterProperties=new FilterProperties();
			filterProperties.setPropertyname(expressionOutputFields.getField().getName());
				if(!outputList.isEmpty()){
					if(!outputList.contains(filterProperties)){
						outputList.forEach(expressionOutputField->expressionOutputField.setPropertyname(filterProperties.getPropertyname()));
						mappingSheetRowSchemaFields.add(SchemaFieldUtil.INSTANCE.getBasicSchemaGridRow(expressionOutputFields.getField()));
					}else{
						mappingSheetRowSchemaFields.add(SchemaFieldUtil.INSTANCE.getBasicSchemaGridRow(expressionOutputFields.getField()));
					}
				}else{
					outputList.add(filterProperties);
					combinedOutputList.add(filterProperties);
					mappingSheetRowSchemaFields.add(SchemaFieldUtil.INSTANCE.getBasicSchemaGridRow(expressionOutputFields.getField()));
				}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:21,代码来源:ExternalOperationExpressionUtil.java

示例3: writeCsv

import java.util.List; //导入方法依赖的package包/类
private static void writeCsv(final String targetName, final LocalDate releaseDate, final List<CodepointCsvRow> emojis) throws IOException {
    try (FileWriter fw = new FileWriter(targetName)) {
        writeCsvRow(fw, "# release date = " + releaseDate.toString());
        writeCsvRow(fw, "# headers = code(s), raw, name, type, properties");
        emojis.forEach(a -> {
            try {
                writeCsvRow(
                        fw,
                        Arrays.stream(a.getCodes()).collect(Collectors.joining(" ")),
                        a.getRaw(),
                        a.getName(),
                        a.getType(),
                        Arrays.stream(a.getFeatures()).collect(Collectors.joining("; "))
                );
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        });
    }
}
 
开发者ID:voho,项目名称:emojava,代码行数:21,代码来源:Generator.java

示例4: removeDuplicates

import java.util.List; //导入方法依赖的package包/类
/**
 * It will be used to remove the duplicate vulnerabilities in the list
 *
 * @param vulnerabilities
 * @return
 */
public static List<Vulnerability> removeDuplicates(List<Vulnerability> vulnerabilities) {
    Map<String, Vulnerability> uniqueKeys = new HashMap<>();
    // Iterate the vulnerabilities to remove the duplicates
    vulnerabilities.forEach(vulnerability -> {
        // The unique vulnerability will be the combination of Component name and version, Channel version and
        // Vulnerability Id
        String uniqueKey = vulnerability.getComponentName() + "~" + vulnerability.getVersion() + "~" + vulnerability.getChannelVersionOriginId() + "~"
                + vulnerability.getVulnerabilityId();

        // If the vulnerability is present in multiple project, then assign the project name and version name to
        // Multiple projects and Multiple versions respectively
        if (uniqueKeys.containsKey(uniqueKey)) {
            vulnerability = new Vulnerability("Multiple projects", "Multiple versions", vulnerability.getProjectId(), vulnerability.getVersionId(),
                    vulnerability.getChannelVersionId(), vulnerability.getComponentName(), vulnerability.getVersion(),
                    vulnerability.getChannelVersionOrigin(), vulnerability.getChannelVersionOriginId(), vulnerability.getChannelVersionOriginName(),
                    vulnerability.getVulnerabilityId(), vulnerability.getDescription(), vulnerability.getPublishedOn(), vulnerability.getUpdatedOn(),
                    vulnerability.getBaseScore(), vulnerability.getExploitability(), vulnerability.getImpact(), vulnerability.getVulnerabilitySource(),
                    vulnerability.getHubVulnerabilityUrl(), vulnerability.getRemediationStatus(), vulnerability.getRemediationTargetDate(),
                    vulnerability.getRemediationActualDate(), vulnerability.getRemediationComment(), vulnerability.getUrl(), vulnerability.getSeverity(),
                    vulnerability.getScanDate());
        }
        uniqueKeys.put(uniqueKey, vulnerability);
    });
    return new ArrayList<>(uniqueKeys.values());
}
 
开发者ID:blackducksoftware,项目名称:hub-fortify-ssc-integration-service,代码行数:32,代码来源:VulnerabilityUtil.java

示例5: checkDuplicatesPruning

import java.util.List; //导入方法依赖的package包/类
@Test(dataProvider = DUPLICATES_PRUNING_PROVIDER)
public void checkDuplicatesPruning(
    List<Runnable> happenedActions,
    Set<UUID> lostReaders,
    Set<Long> inProgress,
    Set<Long> expectedInProgress,
    Set<UUID> expectedLostReaders,
    List<ReaderTxScope> expectedReadTxs
) {
    Mockito.doReturn(CommittedTransactions.INITIAL_READY_COMMIT_ID).when(COMMITTED).getLastDenseCommit();
    happenedActions.forEach(Runnable::run);
    read.scheduleDuplicatesPruning();
    read.pruneCommitted(COMMITTED, heartbeats, lostReaders, inProgress);

    assertEquals(expectedInProgress, inProgress);
    assertEquals(expectedLostReaders, lostReaders);

    Iterator<ReaderTxScope> it = read.iterator();

    for (ReaderTxScope scope : expectedReadTxs) {
        ReaderTxScope actualScope = it.next();

        assertEquals(actualScope.getReaderId(), scope.getReaderId());
        assertEquals(actualScope.getTransactionId(), scope.getTransactionId());
        assertEquals(actualScope.isOrphan(), scope.isOrphan());
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:28,代码来源:ReadTransactionsUnitTest.java

示例6: findAllConnections

import java.util.List; //导入方法依赖的package包/类
@Override
public MultiValueMap<String, Connection<?>> findAllConnections() {
	List<SocialConnectionEntity> socialConnections = connectionRepository.findByUserIdOrderByRankAsc(userId);
	MultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<>();
	socialConnections.forEach(socialConnection -> {
		Connection<?> connection = connectionMapper.mapRow(socialConnection);
		String providerId = connection.getKey().getProviderId();
		connections.add(providerId, connection);
	});
	return connections;
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:12,代码来源:SocialConnectionService.java

示例7: get

import java.util.List; //导入方法依赖的package包/类
public Object get(String cluster, String key) throws Exception {
	List<D_RedisClusterNode> nodes = clusterNodeService.getAllClusterNodes(cluster);
	Set<HostAndPort> masters = new HashSet<HostAndPort>();
	nodes.forEach(node->{
		masters.add(new HostAndPort(node.getHost(), node.getPort()));
	});
	Object value = null;
	JedisCluster jedis = new JedisCluster(masters);
	try {
		String type = jedis.type(key);
		switch (type) {
		case "string":
			value = jedis.get(key);
			break;
		case "list":
			value = jedis.lrange(key, 0, -1);
			break;
		case "set":
			value = jedis.smembers(key);
			break;
		case "zset":
			value = jedis.zrange(key, 0, -1);
			break;
		case "hash":
			value = jedis.hgetAll(key);
			break;
		default:
			break;
		}
	} finally {
		jedis.close();
	}
	return value;
}
 
开发者ID:yanfanvip,项目名称:RedisClusterManager,代码行数:35,代码来源:QueryService.java

示例8: buildSpecificationRows

import java.util.List; //导入方法依赖的package包/类
/**
 * Creates {@link SpecificationRow SpecificationRows} from raw rows.
 *
 * @param validIoVariables variables that might appear in the specification
 * @param durations list of duration for each row
 * @param rawRows Mapping from cycle number x variable name to cell expression as string
 * @return list of specification rows
 */
private static List<SpecificationRow<ConcreteCell>> buildSpecificationRows(
    List<ValidIoVariable> validIoVariables, List<ConcreteDuration> durations,
    Map<Integer, Map<String, String>> rawRows) {
  List<SpecificationRow<ConcreteCell>> specificationRows = new ArrayList<>();
  durations.forEach(
      duration -> buildSpecificationRow(validIoVariables, rawRows, specificationRows, duration));
  return specificationRows;
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:17,代码来源:Z3Solver.java

示例9: getFormatList

import java.util.List; //导入方法依赖的package包/类
public static List<FieldFormat> getFormatList(List<hydrograph.engine.jaxb.ofexcel.FieldFormat.Field> list) {
    List<FieldFormat> fieldFormats = new ArrayList<>();
    list.forEach(element -> {
        FieldFormat f = new FieldFormat();
        f.setName(element.getName());
        if (element.getCopyOfFiled() != null)
            f.setProperty(FieldFormatUtils.setPropertyFromCopyOfFiled(list, element.getCopyOfFiled().getFieldName()));
        else
            f.setProperty(FieldFormatUtils.setProperties(element.getProperty()));
        fieldFormats.add(f);
    });
    return fieldFormats;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:14,代码来源:FieldFormatUtils.java

示例10: respondByTransitionToRegularTask

import java.util.List; //导入方法依赖的package包/类
private String respondByTransitionToRegularTask(TaskDto task) {
  LOGGER.debug("respondByTransitionToRegularTask");

  AttributeGroupDto taskContext = new AttributeGroupDto();
  taskContext.put(KEY_KIND, new StringAttributeValueDto("regular"));

  boolean updateTaskContextResult = updateTaskContext(task.getRef(), taskContext);
  if (false == updateTaskContextResult) {
    respondWithErrorTalkNcco();
  }

  try {
    String convName = attributeGroupDtogetString(KEY_CONV_NAME, task.getUserContext());
    List<Ncco> list = nccoFactory.nccoListWithAnswerFromCustomerForRegularTask(
        MESSAGE_REGULAR_TASK_GREETING, convName, getMusicOnHoldUrl());

    NccoResponseBuilder builder = new NccoResponseBuilder();
    list.forEach(ncco -> {
      builder.appendNcco(ncco);
    });

    NccoResponse nccoResponse = builder.getValue();
    return nccoResponse.toJson();
  } catch (Exception e) {
    LOGGER.error("respondByTransitionToRegularTask: {}", e.getMessage());
  }

  return respondWithErrorTalkNcco();
}
 
开发者ID:Nexmo,项目名称:comms-router,代码行数:30,代码来源:AnswerStrategyWithCallback.java

示例11: test

import java.util.List; //导入方法依赖的package包/类
private void test(int size) {
    final QueueWithStacks queue = new QueueWithStacks();
    List<Integer> integers = StreamUtil.sequence(size);
    integers.forEach(
            i -> queue.enqueue(i)
    );
    integers.forEach(
            i -> assertEquals(i,queue.dequeue())
    );
}
 
开发者ID:gardncl,项目名称:elements-of-programming-interviews-solutions,代码行数:11,代码来源:QueueWithStacksTest.java

示例12: renderGroupNameList

import java.util.List; //导入方法依赖的package包/类
private static final String renderGroupNameList(List<Group> list) {
    StringBuilder sb = new StringBuilder();
    list.forEach(g -> {
        sb.append(g.getName());
        sb.append(", ");
    });
    sb.deleteCharAt(sb.length() - 1); // remove last spcae
    sb.deleteCharAt(sb.length() - 1); // remove last comma
    return sb.toString();
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:11,代码来源:RenderManager.java

示例13: getChildren

import java.util.List; //导入方法依赖的package包/类
@Override
public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) {

    final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class);
    final List<Spatial> children = getSpatials();
    children.forEach(spatial -> result.add(FACTORY_REGISTRY.createFor(spatial)));
    result.addAll(super.getChildren(nodeTree));

    return result;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:11,代码来源:NodeTreeNode.java

示例14: deleteById

import java.util.List; //导入方法依赖的package包/类
@Override
public void deleteById(String index, String type, List<ElasticsearchMetadata.EsRowData> esRowDataList) {
    esRowDataList.forEach(esRowData -> {
        String idColumn = esRowData.getIdColumn();
        String id = (String) esRowData.getRowData().get(idColumn);
        transportClient.prepareDelete(index, type, id).get();
        logger.info("Delete into elasticsearch  ====> {} ", index + "." + type + "." + id);

    });

}
 
开发者ID:zhongchengxcr,项目名称:canal-elasticsearch,代码行数:12,代码来源:ElasticsearchServiceImpl.java

示例15: assertNoTExceptionInvocation

import java.util.List; //导入方法依赖的package包/类
@SafeVarargs
private final void assertNoTExceptionInvocation(
        ResultsSupplier resultsSupplier,
        Collection<Supplier<InvokeRequest>> targets,
        TestingMethodInvocationStatsFactory statsFactory,
        List<TestingExceptionClassifier> classifiers,
        Client client,
        Optional<String> qualifier,
        Throwable testException,
        Class<? extends Throwable>... expectedWrapperTypes)
{
    String name = "exception-" + testException.getClass().getName();

    TestingMethodInvocationStat stat = statsFactory.getStat("clientService", qualifier, "testNoTException");
    stat.clear();
    resultsSupplier.setFailedResult(testException);
    try {
        invocationId++;
        client.testNoTException(invocationId, name);
        fail("Expected exception");
    }
    catch (Throwable e) {
        assertExceptionChain(e, testException, expectedWrapperTypes);
        classifiers.forEach(classifier -> classifier.assertLastException(testException));
    }
    verifyMethodInvocation(targets, "testNoTException", invocationId, name);
    stat.assertFailure(0);
}
 
开发者ID:airlift,项目名称:drift,代码行数:29,代码来源:TestDriftClient.java


注:本文中的java.util.List.forEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。