use of com.vaadin.flow.function.SerializableBiConsumer in project flow by vaadin.
the class WebComponentBinding method bindProperty.
/**
* Adds a property to {@code this} web component binding based on the {@code
* propertyConfiguration}. If a property with an existing name is bound, the
* previous binding is removed.
*
* @param propertyConfiguration
* property configuration, not {@code null}
* @param overrideDefault
* set to {@code true} if the property should be initialized with
* {@code startingValue} instead of default value found in
* {@link PropertyData}
* @param startingValue
* starting value for the property. Can be {@code null}.
* {@code overrideDefault} must be {@code true} for this value to
* have any effect
* @throws NullPointerException
* if {@code propertyConfiguration} is {@code null}
*/
public void bindProperty(PropertyConfigurationImpl<C, ? extends Serializable> propertyConfiguration, boolean overrideDefault, JsonValue startingValue) {
Objects.requireNonNull(propertyConfiguration, "Parameter 'propertyConfiguration' cannot be null!");
final SerializableBiConsumer<C, Serializable> consumer = propertyConfiguration.getOnChangeHandler();
final Serializable selectedStartingValue = !overrideDefault ? propertyConfiguration.getPropertyData().getDefaultValue() : jsonValueToConcreteType(startingValue, propertyConfiguration.getPropertyData().getType());
final PropertyBinding<? extends Serializable> binding = new PropertyBinding<>(propertyConfiguration.getPropertyData(), consumer == null ? null : value -> consumer.accept(component, value), selectedStartingValue);
properties.put(propertyConfiguration.getPropertyData().getName(), binding);
}
Aggregations