/** * Combines the configured filter and the filter from the query into one * filter instance that can be passed to the wrapped data provider using the * {@code filterCombiner}. * * @param filterCombiner * a filters combiner * @param queryFilter * a query filter * @param configuredFilter * a configured filter * @return a filters combination * * @param <F> * the filter type of the wrapped data provider * @param <Q> * the query filter type * @param <C> * the configurable filter type */ public static <F, Q, C> F combineFilters( SerializableBiFunction<Q, C, F> filterCombiner, Q queryFilter, C configuredFilter) { return filterCombiner.apply(queryFilter, configuredFilter); }
private <C extends AbstractField<C, V>, V> SerializableBiFunction<C, V, V> createReader( Element element, String propertyName, SerializableBiFunction<C, P, V> presentationToModel) { return (component, defaultModelValue) -> { if (element.getPropertyRaw(propertyName) != null) { P presentationValue = getter.apply(element, propertyName); return presentationToModel.apply(component, presentationValue); } else { return defaultModelValue; } }; }
/** * Called when the item is updated. By default, a new {@link Component} is * created (via {@link #createComponent(Object)}) when the item is updated, * but setting a update function via the * {@link #ComponentRenderer(SerializableFunction, SerializableBiFunction)} * can change the behavior. * * @param currentComponent * the current component used to render the item, not * <code>null</code> * @param item * the updated item * @return the component that should be used to render the updated item. The * same instance can be returned, or a totally new one, but not * <code>null</code>. */ public Component updateComponent(Component currentComponent, SOURCE item) { if (componentUpdateFunction != null) { return componentUpdateFunction.apply(currentComponent, item); } return createComponent(item); }
private List<String> activate(Range range) { if (range.isEmpty()) { return Collections.emptyList(); } // XXX Explicitly refresh anything that is updated List<String> activeKeys = new ArrayList<>(range.length()); fetchItems.apply(parentKey, range).forEach(bean -> { boolean mapperHasKey = keyMapper.has(bean); String key = keyMapper.key(bean); if (mapperHasKey) { passivatedByUpdate.values() .forEach(set -> set.remove(key)); } activeKeys.add(key); }); return activeKeys; }
/** * Adds a text as a menu item. * * @param text * the text for the menu item * @return a new menu item */ public I addItem(String text) { I menuItem = itemGenerator.apply(menu, contentReset); menuItem.setText(text); add(menuItem); return menuItem; }
/** * Adds a component as a menu item. * * @param component * the component for the menu item * @return a new menu item */ public I addItem(Component component) { I menuItem = itemGenerator.apply(menu, contentReset); add(menuItem); menuItem.add(component); return menuItem; }
private <C extends AbstractField<C, V>, V> SerializableBiConsumer<C, V> createWriter( Element element, String propertyName, SerializableBiFunction<C, V, P> modelToPresentation) { return (component, modelValue) -> { P presentationValue = modelToPresentation.apply(component, modelValue); if (presentationValue == null) { element.removeProperty(propertyName); } else { setter.setElementValue(element, propertyName, presentationValue); } }; } }
private void handlePropertyChange(PropertyChangeEvent event) { if (hasValidValue()) { @SuppressWarnings("unchecked") T presentationValue = propertyReader.apply((C) this, getEmptyValue()); setModelValue(presentationValue, event.isUserOriginated()); } }