Search in sources :

Example 1 with DataCommunicator

use of com.vaadin.flow.data.provider.DataCommunicator in project testbench by vaadin.

the class ComboBoxWrap method getSuggestionItems.

/**
 * Get the actual items for the dropdown as a List. any filter that is set
 * is taken into account.
 *
 * @return List of items
 */
public List<Y> getSuggestionItems() {
    try {
        final Field dataCommunicatorField = getField("dataCommunicator");
        final DataCommunicator<T> dataCommunicator = (DataCommunicator) dataCommunicatorField.get(getComponent());
        final Method fetchFromProvider = getMethod(DataCommunicator.class, "fetchFromProvider", int.class, int.class);
        List<Y> result = ((Stream<Y>) fetchFromProvider.invoke(dataCommunicator, 0, BasicUtilsKt.get_saneFetchLimit())).collect(Collectors.toList());
        return result;
    } catch (IllegalAccessException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
Also used : Field(java.lang.reflect.Field) DataCommunicator(com.vaadin.flow.data.provider.DataCommunicator) Stream(java.util.stream.Stream) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

DataCommunicator (com.vaadin.flow.data.provider.DataCommunicator)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Stream (java.util.stream.Stream)1