List of usage examples for java.util.function BiConsumer accept
void accept(T t, U u);
From source file:org.pentaho.big.data.kettle.plugins.formats.impl.avro.output.AvroOutputDialog.java
private void populateFieldsUI(List<AvroOutputField> fields, TableView wFields, BiConsumer<AvroOutputField, TableItem> converter) { int nrFields = fields.size(); for (int i = 0; i < nrFields; i++) { TableItem item = null;/*from w w w . ja va2 s .c om*/ if (i < wFields.table.getItemCount()) { item = wFields.table.getItem(i); } else { item = new TableItem(wFields.table, SWT.NONE); } converter.accept(fields.get(i), item); } }
From source file:org.pentaho.big.data.kettle.plugins.formats.impl.parquet.output.ParquetOutputDialog.java
private void populateFieldsUI(List<ParquetOutputField> fields, TableView wFields, BiConsumer<ParquetOutputField, TableItem> converter) { for (int i = 0; i < fields.size(); i++) { TableItem item = null;/*www . j a v a 2s .c o m*/ if (i < wFields.table.getItemCount()) { item = wFields.table.getItem(i); } else { item = new TableItem(wFields.table, SWT.NONE); } converter.accept(fields.get(i), item); } }
From source file:org.sejda.impl.sambox.component.AcroFormsMerger.java
private void updateForm(PDAcroForm originalForm, LookupTable<PDAnnotation> widgets, BiFunction<PDTerminalField, LookupTable<PDField>, PDTerminalField> getTerminalField, BiConsumer<PDField, LookupTable<PDField>> createNonTerminalField) { mergeFormDictionary(originalForm);// w w w. ja v a 2 s .c om LookupTable<PDField> fieldsLookup = new LookupTable<>(); for (PDField field : originalForm.getFieldTree()) { if (!field.isTerminal()) { createNonTerminalField.accept(field, fieldsLookup); } else { List<PDAnnotationWidget> relevantWidgets = findMappedWidgetsFor((PDTerminalField) field, widgets); if (!relevantWidgets.isEmpty()) { PDTerminalField terminalField = getTerminalField.apply((PDTerminalField) field, fieldsLookup); if (nonNull(terminalField)) { for (PDAnnotationWidget widget : relevantWidgets) { terminalField.addWidgetIfMissing(widget); } terminalField.getCOSObject().removeItems(WIDGET_KEYS); } } else { LOG.info("Discarded not relevant field {}", field.getPartialName()); } } } this.form.addFields(originalForm.getFields().stream().map(fieldsLookup::lookup).filter(Objects::nonNull) .collect(Collectors.toList())); }
From source file:org.silverpeas.components.formsonline.model.DefaultFormsOnlineService.java
@Override public RequestsByStatus getAllUserRequests(String appId, String userId, final PaginationPage paginationPage) throws FormsOnlineDatabaseException { RequestsByStatus requests = new RequestsByStatus(paginationPage); List<FormDetail> forms = getAllForms(appId, userId, false); for (FormDetail form : forms) { for (Pair<List<Integer>, BiConsumer<RequestsByStatus, SilverpeasList<FormInstance>>> mergingRuleByStates : RequestsByStatus.MERGING_RULES_BY_STATES) { final List<Integer> states = mergingRuleByStates.getLeft(); final BiConsumer<RequestsByStatus, SilverpeasList<FormInstance>> merge = mergingRuleByStates .getRight();/* w w w . j a va2 s .com*/ final PaginationCriterion paginationCriterion = paginationPage != null ? paginationPage.asCriterion() : null; final SilverpeasList<FormInstance> result = getDAO().getSentFormInstances(form.getPK(), userId, states, paginationCriterion); merge.accept(requests, result.stream().map(l -> { l.setForm(form); return l; }).collect(SilverpeasList.collector(result))); } } return requests; }
From source file:org.silverpeas.components.formsonline.model.DefaultFormsOnlineService.java
@Override public RequestsByStatus getValidatorRequests(RequestsFilter filter, String userId, final PaginationPage paginationPage) throws FormsOnlineDatabaseException { final List<String> formIds = getAvailableFormIdsAsReceiver(filter.getComponentId(), userId); // limit requests to specified forms if (!filter.getFormIds().isEmpty()) { formIds.retainAll(filter.getFormIds()); }/* w ww . j a va 2s. com*/ final List<FormDetail> availableForms = getDAO().getForms(formIds); RequestsByStatus requests = new RequestsByStatus(paginationPage); for (FormDetail form : availableForms) { for (Pair<List<Integer>, BiConsumer<RequestsByStatus, SilverpeasList<FormInstance>>> mergingRuleByStates : RequestsByStatus.MERGING_RULES_BY_STATES) { final List<Integer> states = mergingRuleByStates.getLeft(); final BiConsumer<RequestsByStatus, SilverpeasList<FormInstance>> merge = mergingRuleByStates .getRight(); final PaginationCriterion paginationCriterion = paginationPage != null ? paginationPage.asCriterion() : null; final SilverpeasList<FormInstance> result = getDAO().getReceivedRequests(form.getPK(), filter.isAllRequests(), userId, states, paginationCriterion); merge.accept(requests, result.stream().map(l -> { l.setForm(form); return l; }).collect(SilverpeasList.collector(result))); } } return requests; }
From source file:org.silverpeas.core.calendar.icalendar.ICal4JExchangeImportTest.java
/** * Centralization of verification.<br> * <p>// w w w. j av a2 s . c o m * The mechanism is the following:<br> * <p/> * the first parameter represent the name of the file that contains events to import and the * second one is the list of expected calendar events.<br> * Each lines starting with '#' character is ignored. * </p> * @param fileNameOfImport the name of the file that contains events to import. */ @SuppressWarnings({ "unchecked", "Duplicates" }) private void importAndVerifyResult(String fileNameOfImport, List<CalendarEvent> expectedEvents, BiConsumer<Pair<CalendarEvent, List<CalendarEventOccurrence>>, Pair<CalendarEvent, List<CalendarEventOccurrence>>> assertConsumer) throws ImportException { Map<String, Pair<CalendarEvent, List<CalendarEventOccurrence>>> result = new HashedMap<>(); iCalendarImporter.imports( ImportDescriptor.withInputStream(new ByteArrayInputStream( getFileContent(fileNameOfImport).getBytes(StandardCharsets.UTF_8))), events -> result.putAll( events.collect(Collectors.toMap(p -> p.getLeft().getExternalId(), Function.identity())))); Map<String, Pair<CalendarEvent, List<CalendarEventOccurrence>>> expected = expectedEvents.stream().collect( Collectors.toMap(CalendarEvent::getExternalId, e -> Pair.of(e, e.getPersistedOccurrences()))); assertThat("The expected list contains several event with same external id", expected.size(), is(expectedEvents.size())); assertThat(result.keySet(), containsInAnyOrder(expected.keySet().toArray())); result.forEach((i, actualResult) -> { Pair<CalendarEvent, List<CalendarEventOccurrence>> expectedResult = expected.get(i); assertConsumer.accept(actualResult, expectedResult); }); }
From source file:org.sonar.api.config.internal.MapSettingsTest.java
@Test @UseDataProvider("setPropertyCalls") public void all_setProperty_methods_throws_NPE_if_key_is_null(BiConsumer<Settings, String> setPropertyCaller) { Settings settings = new MapSettings(); expectKeyNullNPE();//from w w w.j a v a2 s .com setPropertyCaller.accept(settings, null); }
From source file:org.sonar.api.config.internal.MapSettingsTest.java
@Test @UseDataProvider("setPropertyCalls") public void all_set_property_methods_trims_key(BiConsumer<Settings, String> setPropertyCaller) { Settings underTest = new MapSettings(); Random random = new Random(); String blankBefore = blank(random); String blankAfter = blank(random); String key = randomAlphanumeric(3); setPropertyCaller.accept(underTest, blankBefore + key + blankAfter); assertThat(underTest.hasKey(key)).isTrue(); }
From source file:org.sonar.api.config.PropertyDefinitionTest.java
private static void failsWithIAEForUnsupportedQualifiers( BiConsumer<PropertyDefinition.Builder, String> biConsumer) { PropertyDefinition.Builder builder = PropertyDefinition.builder(randomAlphabetic(3)); NOT_ALLOWED_QUALIFIERS.forEach(qualifier -> { try {/* w w w . j ava2 s . c om*/ biConsumer.accept(builder, qualifier); fail("A IllegalArgumentException should have been thrown for qualifier " + qualifier); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Qualifier must be one of [TRK, VW, BRC, SVW, APP]"); } }); }
From source file:org.sonar.api.config.PropertyDefinitionTest.java
private static void acceptsSupportedQualifiers(BiConsumer<PropertyDefinition.Builder, String> biConsumer) { PropertyDefinition.Builder builder = PropertyDefinition.builder(randomAlphabetic(3)); ALLOWED_QUALIFIERS.forEach(qualifier -> biConsumer.accept(builder, qualifier)); }