本文整理了Java中java.util.List.replaceAll()
方法的一些代码示例,展示了List.replaceAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.replaceAll()
方法的具体详情如下:
包路径:java.util.List
类名称:List
方法名:replaceAll
暂无
代码示例来源:origin: google/guava
@Override
public void replaceAll(UnaryOperator<E> operator) {
synchronized (mutex) {
delegate().replaceAll(operator);
}
}
代码示例来源:origin: prestodb/presto
@Override
public void replaceAll(UnaryOperator<E> operator) {
synchronized (mutex) {
delegate().replaceAll(operator);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public void replaceAll(UnaryOperator<E> operator) {
synchronized (mutex) {
delegate().replaceAll(operator);
}
}
代码示例来源:origin: konsoletyper/teavm
@Override
public void visit(InvokeDynamicInstruction insn) {
Optional.ofNullable(insn.getInstance()).map(mapper).ifPresent(insn::setInstance);
insn.getArguments().replaceAll(mapper);
}
代码示例来源:origin: apache/geode
/**
* @param buffer use the buffer to find the completion candidates
*
* Note the cursor may not be the size the buffer
*/
private List<Completion> getCandidates(String buffer) {
List<Completion> candidates = new ArrayList<>();
// always pass the buffer length as the cursor position for simplicity purpose
super.completeAdvanced(buffer, buffer.length(), candidates);
// trimming the candidates
candidates.replaceAll(completion -> new Completion(completion.getValue().trim()));
return candidates;
}
}
代码示例来源:origin: google/guava
@ListFeature.Require(SUPPORTS_SET)
public void testReplaceAll_changesSome() {
getList().replaceAll(e -> e.equals(samples.e0()) ? samples.e3() : e);
E[] expected = createSamplesArray();
for (int i = 0; i < expected.length; i++) {
if (expected[i].equals(samples.e0())) {
expected[i] = samples.e3();
}
}
expectContents(expected);
}
代码示例来源:origin: google/guava
@ListFeature.Require(SUPPORTS_SET)
public void testReplaceAll() {
getList().replaceAll(e -> samples.e3());
expectContents(Collections.nCopies(getNumElements(), samples.e3()));
}
代码示例来源:origin: google/guava
@CollectionSize.Require(absent = ZERO)
@ListFeature.Require(absent = SUPPORTS_SET)
public void testReplaceAll_unsupported() {
try {
getList().replaceAll(e -> e);
fail("replaceAll() should throw UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
}
expectUnchanged();
}
}
代码示例来源:origin: jankotek/mapdb
public void testReplaceAllIsNotStructuralModification() {
Collection c = impl.emptyCollection();
if (!(c instanceof List))
return;
List list = (List) c;
ThreadLocalRandom rnd = ThreadLocalRandom.current();
for (int n = rnd.nextInt(2, 10); n--> 0; )
list.add(impl.makeElement(rnd.nextInt()));
ArrayList copy = new ArrayList(list);
int size = list.size(), half = size / 2;
Iterator it = list.iterator();
for (int i = 0; i < half; i++)
assertEquals(it.next(), copy.get(i));
list.replaceAll(n -> n);
// ConcurrentModificationException must not be thrown here.
for (int i = half; i < size; i++)
assertEquals(it.next(), copy.get(i));
}
代码示例来源:origin: apache/geode
potentials.replaceAll(
completion -> new Completion(completion.getValue().substring(candidateBeginAt)));
potentials.replaceAll(completion -> new Completion("=" + completion.getValue()));
代码示例来源:origin: debezium/debezium
@Override
public TableEditor renameColumn(String existingName, String newName) {
final Column existing = columnWithName(existingName);
if (existing == null) throw new IllegalArgumentException("No column with name '" + existingName + "'");
Column newColumn = existing.edit().name(newName).create();
// Determine the primary key names ...
List<String> newPkNames = null;
if ( !hasUniqueValues() && primaryKeyColumnNames().contains(existing.name())) {
newPkNames = new ArrayList<>(primaryKeyColumnNames());
newPkNames.replaceAll(name->existing.name().equals(name) ? newName : name);
}
// Add the new column, move it before the existing column, and remove the old column ...
addColumn(newColumn);
reorderColumn(newColumn.name(), existing.name());
removeColumn(existing.name());
if (newPkNames != null) {
setPrimaryKeyNames(newPkNames);
}
return this;
}
代码示例来源:origin: stackoverflow.com
List<Integer> l = Arrays.asList(2,3,6,1,9);
l.replaceAll(p->p*2);
代码示例来源:origin: ebean-orm/ebean
@Override
public void replaceAll(UnaryOperator<E> operator) {
checkCopyOnWrite();
list.replaceAll(operator);
}
代码示例来源:origin: diffplug/spotless
/** If the user hasn't specified the files yet, we'll assume he/she means all of the java files. */
@Override
protected void setupTask(SpotlessTask task) {
if (target == null) {
JavaPluginConvention javaPlugin = getProject().getConvention().findPlugin(JavaPluginConvention.class);
if (javaPlugin == null) {
throw new GradleException("You must apply the java plugin before the spotless plugin if you are using the java extension.");
}
FileCollection union = getProject().files();
for (SourceSet sourceSet : javaPlugin.getSourceSets()) {
union = union.plus(sourceSet.getAllJava());
}
target = union;
}
steps.replaceAll(step -> {
if (LicenseHeaderStep.name().equals(step.getName())) {
return step.filterByFile(LicenseHeaderStep.unsupportedJvmFilesFilter());
} else {
return step;
}
});
super.setupTask(task);
}
}
代码示例来源:origin: diffplug/spotless
steps.replaceAll(step -> {
if (LicenseHeaderStep.name().equals(step.getName())) {
return step.filterByFile(LicenseHeaderStep.unsupportedJvmFilesFilter());
代码示例来源:origin: stackoverflow.com
String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
"Jupiter", "Saturn", "Uranus", "Neptune" };
Arrays.asList(planets).replaceAll(s -> new StringBuilder(s).reverse().toString());
System.out.println(Arrays.toString(planets));
// [yrucreM, suneV, htraE, sraM, retipuJ, nrutaS, sunarU, enutpeN]
代码示例来源:origin: OpenGamma/Strata
@Override
public MutablePointSensitivities withCurrency(Currency currency) {
sensitivities.replaceAll(ps -> ps.withCurrency(currency));
return this;
}
代码示例来源:origin: org.weakref/jmxutils
@Override
public void replaceAll(UnaryOperator<E> operator) {
synchronized (mutex) {
delegate().replaceAll(operator);
}
}
代码示例来源:origin: com.google.guava/guava-testlib
@ListFeature.Require(SUPPORTS_SET)
public void testReplaceAll() {
getList().replaceAll(e -> samples.e3());
expectContents(Collections.nCopies(getNumElements(), samples.e3()));
}
代码示例来源:origin: com.google.guava/guava-testlib
@CollectionSize.Require(absent = ZERO)
@ListFeature.Require(absent = SUPPORTS_SET)
public void testReplaceAll_unsupported() {
try {
getList().replaceAll(e -> e);
fail("replaceAll() should throw UnsupportedOperationException");
} catch (UnsupportedOperationException expected) {
}
expectUnchanged();
}
}
内容来源于网络,如有侵权,请联系作者删除!