Package com.vaadin.featurepack.data.util
Class NestedMethodProperty<T>
java.lang.Object
com.vaadin.featurepack.data.util.AbstractProperty<T>
com.vaadin.featurepack.data.util.NestedMethodProperty<T>
- All Implemented Interfaces:
Property<T>,Property.ReadOnlyStatusChangeNotifier,Property.ValueChangeNotifier,Serializable
Nested accessor based property for a bean.
The property is specified in the dotted notation, e.g. "address.street", and
can contain multiple levels of nesting.
When accessing the property value, all intermediate getters must exist and
should return non-null values when the property value is accessed. If an
intermediate getter returns null, a null value will be returned.
- Since:
- 6.6
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.featurepack.data.util.AbstractProperty
AbstractProperty.ReadOnlyStatusChangeEventNested classes/interfaces inherited from interface com.vaadin.featurepack.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer -
Constructor Summary
ConstructorsConstructorDescriptionNestedMethodProperty(Object instance, String propertyName) Constructs a nested method property for a given object instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable list of getter methods to call in sequence to get the property value.The instance used by this propertygetType()Returns the type of the Property.getValue()Gets the value stored in the Property.protected voidinvokeSetMethod(T value) Internal method to actually call the setter method of the wrapped property.booleanTests if the Property is in read-only mode.voidsetInstance(Object instance) Sets the instance used by this property.voidSets the value of the property.Methods inherited from class com.vaadin.featurepack.data.util.AbstractProperty
addReadOnlyStatusChangeListener, addValueChangeListener, fireReadOnlyStatusChange, fireValueChange, getListeners, removeReadOnlyStatusChangeListener, removeValueChangeListener, setPropertyReadOnly
-
Constructor Details
-
NestedMethodProperty
Constructs a nested method property for a given object instance. The property name is a dot separated string pointing to a nested property, e.g. "manager.address.street".Calling getValue will return null if any intermediate getter returns null
- Parameters:
instance- top-level bean to which the property appliespropertyName- dot separated nested property name- Throws:
IllegalArgumentException- if the property name is invalid
-
-
Method Details
-
getType
Description copied from interface:PropertyReturns the type of the Property. The methodsgetValueandsetValuemust be compatible with this type: one must be able to safely cast the value returned fromgetValueto the given type and pass any variable assignable to this type as an argument tosetValue.- Returns:
- type of the Property
-
isPropertyReadOnly
public boolean isPropertyReadOnly()Description copied from class:AbstractPropertyTests if the Property is in read-only mode. In read-only mode calls to the methodsetValuewill throwReadOnlyExceptionand will not modify the value of the Property. Override for additional restrictions on what is considered a read-only property.- Specified by:
isPropertyReadOnlyin interfaceProperty<T>- Overrides:
isPropertyReadOnlyin classAbstractProperty<T>- Returns:
trueif the Property is in read-only mode,falseif it's not
-
getValue
Gets the value stored in the Property. The value is resolved by calling the specified getter methods on the current instance:- Returns:
- the value of the Property
- See Also:
-
setValue
Sets the value of the property. The new value must be assignable to the type of this property.- Parameters:
newValue- the New value of the property.- Throws:
Property.ReadOnlyException- if the object is in read-only mode- See Also:
-
invokeSetMethod
Internal method to actually call the setter method of the wrapped property.- Parameters:
value-
-
getGetMethods
Returns an unmodifiable list of getter methods to call in sequence to get the property value. This API may change in future versions.- Returns:
- unmodifiable list of getter methods corresponding to each segment of the property name
-
getInstance
The instance used by this property- Returns:
- the instance used for fetching the property value
- Since:
- 7.7.7
-
setInstance
Sets the instance used by this property.The new instance must be of the same type as the old instance
To be consistent with
setValue(Object), this method will fire a value change event even if the value stays the same- Parameters:
instance- the instance to use- Since:
- 7.7.7
-