當前位置: 首頁>>代碼示例>>Java>>正文


Java List.replaceAll方法代碼示例

本文整理匯總了Java中java.util.List.replaceAll方法的典型用法代碼示例。如果您正苦於以下問題:Java List.replaceAll方法的具體用法?Java List.replaceAll怎麽用?Java List.replaceAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.List的用法示例。


在下文中一共展示了List.replaceAll方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: modifyBasePolygonDeform

import java.util.List; //導入方法依賴的package包/類
private Polygon2D modifyBasePolygonDeform(Polygon2D toModify)
{
	Vector2D center = toModify.getPointCenter();
	Vector2D point = RandomUtil.getElement(toModify.points, this.random);

	Vector2D centerToPoint = point.subtract(center);
	Vector2D ctpDirection = centerToPoint.normalize();
	Vector2D ctpOrthogonal = center.orthogonal().normalize();

	Vector2D pointDeltaForward = ctpDirection.multiply(RandomUtil.distribute(0.05, 0.1, this.random));
	Vector2D pointDeltaSideward = ctpOrthogonal.multiply(RandomUtil.distribute(0.05, 0.1, this.random));
	Vector2D pointDelta = pointDeltaForward.add(pointDeltaSideward);

	Vector2D newPoint = point.add(pointDelta);
	List<Vector2D> newPoints = new ArrayList<>(toModify.points);
	newPoints.replaceAll((p)->Objects.equals(p, point) ? newPoint : p); // replace the old point with the new one

	return new Polygon2D(newPoints);
}
 
開發者ID:domisum,項目名稱:ExZiff,代碼行數:20,代碼來源:ContinentsBasePolygonGenerator.java

示例2: testReplaceAllThrowsCME

import java.util.List; //導入方法依賴的package包/類
@Test
public void testReplaceAllThrowsCME() {
    @SuppressWarnings("unchecked")
    final CollectionSupplier<List<Integer>> supplier = new CollectionSupplier(LIST_CME_SUPPLIERS, SIZE);
    for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) {
        final List<Integer> list = test.collection;

        if (list.size() <= 1) {
            continue;
        }
        boolean gotException = false;
        try {
            // bad predicate that modifies its list, should throw CME
            list.replaceAll(x -> {int n = 3 * x; list.add(n); return n;});
        } catch (ConcurrentModificationException cme) {
            gotException = true;
        }
        if (!gotException) {
            fail("expected CME was not thrown from " + test);
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:ListDefaults.java

示例3: updateNames

import java.util.List; //導入方法依賴的package包/類
public List<Employee> updateNames(){
	List<Employee> newListEmps= employeeDaoImpl.getEmployees();
	newListEmps.replaceAll((e) ->{
		e.setFirstName(e.getFirstName().toUpperCase());
		e.setLastName(e.getLastName().toUpperCase());
		return e;
	});
	
	return newListEmps;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:11,代碼來源:EmployeeStreamService.java

示例4: runReplaceAll

import java.util.List; //導入方法依賴的package包/類
void runReplaceAll(List<StringHolder> a, List<StringHolder> b) {
	a.replaceAll((StringHolder t)->{t.concat("@JJ17r");return new StringHolder(t.getString() + "@417b");});
	int x = 0;
	while (x<b.size()) {
		assertTrue("Expected \"" + b.get(x).getString() + "[email protected]@417b\" but found \"" + a.get(x).getString(),a.get(x).getString().equals(b.get(x).getString() + "[email protected]@417b"));
		x++;
	}
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:9,代碼來源:ClassLibraryLambdaTests.java

示例5: updateColumns

import java.util.List; //導入方法依賴的package包/類
private void updateColumns(List<Column> newColumns) {
    List<Column> currentColumns = report.getColumns();
    newColumns = new ArrayList<>(newColumns);
    newColumns.replaceAll(column -> {
        if (currentColumns.contains(column)) {
            return currentColumns.get(currentColumns.indexOf(column));
        }
        return column;
    });
    report.clearColumns();
    newColumns.forEach(report::addColumn);
    report.setQuery(queryArea.getText().trim());
}
 
開發者ID:NVIvanov,項目名稱:jrbuilder,代碼行數:14,代碼來源:ReportForm.java

示例6: testIds2List

import java.util.List; //導入方法依賴的package包/類
/**
 * In case of multiple value for the "heatTest" parameter, it splits the values and runs tests one by one.
 * @param testIds string containing all the test ids to run, split with a separator
 * @return a list of test ids
 */
private List<String> testIds2List(String testIds) {
    List<String> testIdsList = new ArrayList<>();

    if (testIds != null) {
        testIdsList.addAll(Arrays.asList(testIds.split(HEAT_TEST_SEPARATOR)));
        testIdsList.replaceAll(String::trim);
    }
    return testIdsList;
}
 
開發者ID:HotelsDotCom,項目名稱:heat,代碼行數:15,代碼來源:EnvironmentHandler.java

示例7: createResultTree

import java.util.List; //導入方法依賴的package包/類
/**
 * This method will generate the resulting aggregated data tree
 *
 * @param dataStore
 *            - the RLCDataStore that was used to collect all the data for
 *            the RLCs processed
 * @param configurationDataStore
 *            - the ConfigurationDataStore that was used to collect all the
 *            data for the RLCs processed
 * @param dataStoreMap
 *            - the DataStoreMap that is used to collect the names of the
 *            different RLCs processed
 * @return JScrollPane
 */
public JScrollPane createResultTree(final RLCDataStore dataStore,
                                    final ConfigurationDataStore configurationDataStore, final Map<String, RLCDataStore> dataStoreMap) {
	final DefaultMutableTreeNode top = new DefaultMutableTreeNode("root");

	final RLCDataAnalyser dataAnalyser = new RLCDataAnalyser(dataStore);
	final List<String> fileNameHeaderList;


	final DefaultMutableTreeNode summary = new DefaultMutableTreeNode("Summary");
	final DefaultMutableTreeNode rlcSummary = new DefaultMutableTreeNode("RLC Information");

	addATreeNode(summary, "Total number of Lockers", dataStore.getTotalCounts(TotalCountDataType.Lockers));
	addATreeNode(summary, "Total number of Routes", dataStore.getTotalCounts(TotalCountDataType.Routes));
	addATreeNode(summary, "Total number of Communication Points",
	             dataStore.getTotalCounts(TotalCountDataType.CommunicationPoints));

	addATreeNode(summary, "Total number of Filters", dataAnalyser.getNumberOfFilters());
	addATreeNode(summary, "Total number of Web Services", dataStore.getTotalCounts(TotalCountDataType.WebServices));
	addATreeNode(summary, "Total number of Definitions", dataStore.getTotalCounts(TotalCountDataType.Definitions));
	addATreeNode(summary, "Total number of Message Tracking Schemes",
	             dataStore.getTotalCounts(TotalCountDataType.MessageTrackingSchemes));
	addATreeNode(summary, "Total number of REST Clients", dataStore.getTotalCounts(TotalCountDataType.RESTClients));
	addATreeNode(summary, "Total number of Variables", dataStore.getTotalCounts(TotalCountDataType.Variables));
	addATreeNode(summary, "Total number of Lookup Tables",
	             dataStore.getTotalCounts(TotalCountDataType.LookupTables));
	addATreeNode(summary, "Total number of Shared JavaScript Libraries",
	             dataStore.getTotalCounts(TotalCountDataType.SharedJSLibraries));

	fileNameHeaderList = new ArrayList<String>(dataStoreMap.keySet());
	fileNameHeaderList.replaceAll(fileName -> fileName.substring(fileName.indexOf(":") + 1));

	// Add the tree structure to the root
	addATreeNode(rlcSummary, "Total number of RLC files processed", fileNameHeaderList.size());
	addResultsTreeNode(rlcSummary, "RLCs Processed", fileNameHeaderList);

	top.add(summary);
	top.add(rlcSummary);

	return new JScrollPane(manipulateJTree(top));
}
 
開發者ID:orionhealth,項目名稱:rlc-analyser,代碼行數:55,代碼來源:RLCTreeBuilder.java

示例8: processCommand

import java.util.List; //導入方法依賴的package包/類
private boolean processCommand(String rawString) {
    boolean ret = false;
    final Scanner sc = new Scanner(rawString);
    final String command = sc.next();
    List<String> parms;
    if (sc.hasNextLine()) {
        final String[] rawParms = sc.nextLine().split(",");
        parms = Arrays.asList(rawParms);
        parms.replaceAll(String::trim);
    } else {
        parms = new ArrayList<String>();
    }
    
    switch(command.toUpperCase()) {
        case "GET_ALL" :
            doGetAll(parms);
            break;
        case "GET" :
            doGet(parms);
            break;
        case "PUT" :
            doPut(parms);
            break;
        case "PUT_IF_ABSENT" :
            doPutIfAbsent(parms);
            break;
        case "REMOVE" :
            doRemove(parms);
            break;
        case "REPLACE" :
            doReplace(parms);
            break;
        case "CLEAR" :
            doClear(parms);
            break;
        case "REFRESH" :
            doRefresh(parms);
            break;
        case "HELP" :
            doHelp(parms);
            break;
        case "QUIT" :
            ret = true;
            output("Exiting...%n");
            break;
        default :
            unknownCommand(command);
            break;
    }
    sc.close();
    return ret;
}
 
開發者ID:pravega,項目名稱:pravega-samples,代碼行數:53,代碼來源:SharedConfigCli.java

示例9: processCommand

import java.util.List; //導入方法依賴的package包/類
private boolean processCommand(String rawString) {
    boolean ret = false;
    final Scanner sc = new Scanner(rawString);
    final String command = sc.next();
    List<String> parms;
    final String restOfLine;
    if (sc.hasNextLine()) {
        restOfLine = sc.nextLine();
        final String[] rawParms = restOfLine.split(",");
        parms = Arrays.asList(rawParms);
        parms.replaceAll(String::trim);
    } else {
        parms = new ArrayList<String>();
        restOfLine = null;
    }
    
    switch(command.toUpperCase()) {
        case "WRITE_EVENT":
            doWriteEvent(restOfLine);
            break;
        case "WRITE_EVENT_RK":
            doWriteEventRK(restOfLine);
            break;
        case "BEGIN":
            doBeginTxn(parms);
            break;
        case "GET_TXN_ID":
            doGetTxnId(parms);
            break;
        case "FLUSH":
            doFlushTxn(parms);
            break;
        case "COMMIT":
            doCommitTxn(parms);
            break;
        case "ABORT":
            doAbortTxn(parms);
            break;
        case "STATUS":
            doCheckTxnStatus(parms);
            break;
        case "HELP" :
            doHelp(parms);
            break;
        case "QUIT" :
            ret = true;
            output("Exiting...%n");
            break;
        default :
            doWriteEvent(rawString);
            break;
    }
    sc.close();
    return ret;
}
 
開發者ID:pravega,項目名稱:pravega-samples,代碼行數:56,代碼來源:ConsoleWriter.java

示例10: loadCharacterData

import java.util.List; //導入方法依賴的package包/類
/**
 * Loads character data from a path.
 *
 * @param inputStream
 *         The input stream.
 *
 * @return
 *         The character data.
 *
 * @throws NullPointerException
 *         If the input stream is null.
 *
 * @throws IOException
 *         If an IOException occurs while loading the character data.
 */
private static List<String> loadCharacterData(final @NonNull InputStream inputStream) throws IOException {
    // Load lines
    final InputStreamReader isr = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
    final BufferedReader br = new BufferedReader(isr);
    List<String> lines = br.lines().collect(Collectors.toList());

    // Remove unnecessary data:
    final Pattern pattern = Pattern.compile("info.*|common.*|page.*|chars.*|char id=\\d\\d\\d\\d\\d\\d.*|char id=[7-9]\\d\\d\\d\\d.*|char id=6[6-9]\\d\\d\\d.*|char id=65[6-9]\\d\\d.*|char id=655[4-9]\\d.*|char id=6553[6-9].*| xoff.*|char id=|x=|y=|width=|height=");
    lines.replaceAll(string -> pattern.matcher(string).replaceAll(""));
    lines.removeIf(String::isEmpty);

    inputStream.close();
    return lines;
}
 
開發者ID:Valkryst,項目名稱:VTerminal,代碼行數:30,代碼來源:FontLoader.java


注:本文中的java.util.List.replaceAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。