當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。