com.holonplatform.vaadin.components.PropertyInputBinder Maven / Gradle / Ivy
/*
* Copyright 2016-2017 Axioma srl.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.holonplatform.vaadin.components;
import java.io.Serializable;
import java.util.Optional;
import java.util.stream.Stream;
import com.holonplatform.core.property.Property;
import com.holonplatform.core.property.Property.PropertyNotFoundException;
import com.holonplatform.core.property.VirtualProperty;
import com.holonplatform.vaadin.components.ValueHolder.ValueChangeEvent;
/**
* Represents a component which binds a property set to {@link Input} components.
*
* Provides methods to obtain the property set and the property-input bindings, for example to get the {@link Input}
* bound to a specific property.
*
*
* @since 5.0.5
*/
public interface PropertyInputBinder extends PropertySetBound {
/**
* Gets all the {@link Input}s that have been bound to a property.
* @return An {@link Iterable} on all bound {@link Input}s
*/
Iterable> getInputs();
/**
* Get the {@link Input} bound to given property
, if any.
* @param Property type
* @param property Property for which to get the associated {@link Input} (not null)
* @return Optional {@link Input} bound to given property
*/
Optional> getInput(Property property);
/**
* Get the {@link Input} bound to given property
, if any. If not available, a
* {@link PropertyNotFoundException} is thrown.
* @param Property type
* @param property Property for which to get the associated {@link Input} (not null)
* @return the {@link Input} bound to given property
* @throws PropertyNotFoundException If no Input is available for given property
*/
default Input requireInput(Property property) {
return getInput(property).orElseThrow(
() -> new PropertyNotFoundException(property, "No Input available for property [" + property + "]"));
}
/**
* Return a {@link Stream} of the properties and their bound {@link Input}s of this input group.
* @param Property type
* @return Property-Input {@link PropertyBinding} stream
*/
Stream>> stream();
/**
* Refresh the value of all available {@link Input}s, using current values.
*/
default void refresh() {
refresh(false);
}
/**
* Refresh the value of all available {@link Input}s, using current values.
* @param readOnly true
to refresh only the {@link Input}s bound to read-only properties,
* false
to refresh all
*/
void refresh(boolean readOnly);
/**
* Refresh the value of the {@link Input} bound to given property
, if available, using currently
* available values.
*
* For read-only properties such as {@link VirtualProperty}s, this has the effect to recalculate the virtual value
* according to the values currently set in all the binder inputs.
*
* @param property The property for which to refresh the bound {@link Input}
*/
void refresh(Property property);
// Value change listener
/**
* A listener for {@link Input} value change events when the {@link Input} is bound to a {@link Property} within a
* {@link PropertyInputBinder} component.
* @param Value type
*/
@FunctionalInterface
public interface PropertyInputValueChangeListener extends Serializable {
/**
* Invoked when this listener receives a value change event from an {@link ValueHolder} source to which it has
* been added within a {@link PropertyInputBinder}.
* @param event the value change event
* @param binder The {@link PropertyInputBinder} to which the value change source belongs
*/
void valueChange(ValueChangeEvent event, PropertyInputBinder binder);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy