Class PropertyConfigurationImpl<C extends Component,P extends Serializable>
- java.lang.Object
-
- com.vaadin.flow.server.webcomponent.PropertyConfigurationImpl<C,P>
-
- Type Parameters:
C
- type of the exportedcomponent
P
- type of the property
- All Implemented Interfaces:
PropertyConfiguration<C,P>
,Serializable
public final class PropertyConfigurationImpl<C extends Component,P extends Serializable> extends Object implements PropertyConfiguration<C,P>
For internal use only. May be renamed or removed in a future release.- Since:
- 2.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
SerializableBiConsumer<C,Serializable>
getOnChangeHandler()
Retrieves theonChangeHandler
tied to this property, if one exists.PropertyData<P>
getPropertyData()
ComputedPropertyData
based on the configuration details.int
hashCode()
PropertyConfiguration<C,P>
onChange(SerializableBiConsumer<C,P> onChangeHandler)
Sets a Property change handler.PropertyConfiguration<C,P>
readOnly()
Mark the property as read-only.
-
-
-
Constructor Detail
-
PropertyConfigurationImpl
public PropertyConfigurationImpl(Class<C> componentType, String propertyName, Class<P> propertyType, P defaultValue)
Constructs a newPropertyConfigurationImpl
tied to the exportedComponent
type given bycomponentType
.- Parameters:
componentType
- type of the exportedcomponent
propertyName
- name of the propertypropertyType
- type of the propertydefaultValue
- 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 anull
.
-
-
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 isnull
for a property type which should not receive null-values, such asdouble
, the method will be called with the property's default value. The default value is set byWebComponentExporter
whenaddProperty(propertyName, defaultValue
is called.In the following example we export
MyComponent
as a web component. TheMyComponent
class has a methodsetName
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 interfacePropertyConfiguration<C extends Component,P extends Serializable>
- Parameters:
onChangeHandler
-component
's method which is called with the property value- Returns:
- this
PropertyConfiguration
-
readOnly
public PropertyConfiguration<C,P> readOnly()
Description copied from interface:PropertyConfiguration
Mark the property as read-only. It cannot be written to by the client.- Specified by:
readOnly
in interfacePropertyConfiguration<C extends Component,P extends Serializable>
- Returns:
- this
PropertyConfiguration
-
getOnChangeHandler
public SerializableBiConsumer<C,Serializable> getOnChangeHandler()
Retrieves theonChangeHandler
tied to this property, if one exists.- Returns:
- handler or
null
-
getPropertyData
public PropertyData<P> getPropertyData()
ComputedPropertyData
based on the configuration details.- Returns:
PropertyData
value object
-
-