@Override public void replaceAll(UnaryOperator<E> operator) { synchronized (mutex) { delegate().replaceAll(operator); } }
@Override public void replaceAll(UnaryOperator<E> operator) { synchronized (mutex) { delegate().replaceAll(operator); } }
@Override public void replaceAll(UnaryOperator<E> operator) { synchronized (mutex) { delegate().replaceAll(operator); } }
@Override public void visit(InvokeDynamicInstruction insn) { Optional.ofNullable(insn.getInstance()).map(mapper).ifPresent(insn::setInstance); insn.getArguments().replaceAll(mapper); }
/** * @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; } }
@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); }
@ListFeature.Require(SUPPORTS_SET) public void testReplaceAll() { getList().replaceAll(e -> samples.e3()); expectContents(Collections.nCopies(getNumElements(), samples.e3())); }
@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(); } }
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)); }
potentials.replaceAll( completion -> new Completion(completion.getValue().substring(candidateBeginAt))); potentials.replaceAll(completion -> new Completion("=" + completion.getValue()));
@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; }
List<Integer> l = Arrays.asList(2,3,6,1,9); l.replaceAll(p->p*2);
@Override public void replaceAll(UnaryOperator<E> operator) { checkCopyOnWrite(); list.replaceAll(operator); }
/** 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); } }
steps.replaceAll(step -> { if (LicenseHeaderStep.name().equals(step.getName())) { return step.filterByFile(LicenseHeaderStep.unsupportedJvmFilesFilter());
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]
@Override public MutablePointSensitivities withCurrency(Currency currency) { sensitivities.replaceAll(ps -> ps.withCurrency(currency)); return this; }
@Override public void replaceAll(UnaryOperator<E> operator) { synchronized (mutex) { delegate().replaceAll(operator); } }
@ListFeature.Require(SUPPORTS_SET) public void testReplaceAll() { getList().replaceAll(e -> samples.e3()); expectContents(Collections.nCopies(getNumElements(), samples.e3())); }
@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(); } }