本文整理汇总了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);
}
示例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);
}
}
}
示例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;
}
示例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++;
}
}
示例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());
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}