Class PropertyConfigurationImpl<C extends Component,​P extends Serializable>

    • Constructor Detail

      • PropertyConfigurationImpl

        public PropertyConfigurationImpl​(Class<C> componentType,
                                         String propertyName,
                                         Class<P> propertyType,
                                         P defaultValue)
        Constructs a new PropertyConfigurationImpl tied to the exported Component type given by componentType.
        Parameters:
        componentType - type of the exported component
        propertyName - name of the property
        propertyType - type of the property
        defaultValue - default value of the property. If the property type has a primitive version, this value is used when ever the property is being set to a null.
    • Method Detail

      • onChange

        public PropertyConfiguration<C,​P> onChange​(SerializableBiConsumer<C,​P> onChangeHandler)
        Description copied from interface: PropertyConfiguration
        Sets a Property change handler. onChange can only be called once - multiple calls will throw an exception.

        The onChangeHandler is called when the property's value changes on the client-side. If the property value is null for a property type which should not receive null-values, such as double, the method will be called with the property's default value. The default value is set by WebComponentExporter when addProperty(propertyName, defaultValue is called.

        In the following example we export MyComponent as a web component. The MyComponent class has a method setName which will be called in response to changes to the registered property "name".

         @Tag("my-component")
         public class Exporter implements WebComponentExporter<MyComponent>() {
             // ... define the web component
             public Exporter() {
                 super("my-component");
                 addProperty("name", "John Doe").onChange(MyComponent::setName);
             }
         }
         
        Specified by:
        onChange in interface PropertyConfiguration<C extends Component,​P extends Serializable>
        Parameters:
        onChangeHandler - component's method which is called with the property value
        Returns:
        this PropertyConfiguration
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getOnChangeHandler

        public SerializableBiConsumer<C,​Serializable> getOnChangeHandler()
        Retrieves the onChangeHandler tied to this property, if one exists.
        Returns:
        handler or null
      • getPropertyData

        public PropertyData<P> getPropertyData()
        Computed PropertyData based on the configuration details.
        Returns:
        PropertyData value object