Package com.vaadin.data.util
Class NestedMethodProperty<T>
- java.lang.Object
-
- com.vaadin.data.util.AbstractProperty<T>
-
- com.vaadin.data.util.NestedMethodProperty<T>
-
- All Implemented Interfaces:
Property<T>
,Property.ReadOnlyStatusChangeNotifier
,Property.ValueChangeNotifier
,Serializable
public class NestedMethodProperty<T> extends AbstractProperty<T>
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:
MethodProperty
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.data.util.AbstractProperty
AbstractProperty.ReadOnlyStatusChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
-
-
Constructor Summary
Constructors Constructor Description NestedMethodProperty(Object instance, String propertyName)
Constructs a nested method property for a given object instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Method>
getGetMethods()
Returns an unmodifiable list of getter methods to call in sequence to get the property value.Object
getInstance()
The instance used by this propertyClass<? extends T>
getType()
Returns the type of the Property.T
getValue()
Gets the value stored in the Property.protected void
invokeSetMethod(T value)
Internal method to actually call the setter method of the wrapped property.boolean
isReadOnly()
Tests if the Property is in read-only mode.void
setInstance(Object instance)
Sets the instance used by this property.void
setValue(T newValue)
Sets the value of the property.-
Methods inherited from class com.vaadin.data.util.AbstractProperty
addListener, addListener, addReadOnlyStatusChangeListener, addValueChangeListener, fireReadOnlyStatusChange, fireValueChange, getListeners, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValueChangeListener, setReadOnly, toString
-
-
-
-
Constructor Detail
-
NestedMethodProperty
public NestedMethodProperty(Object instance, String propertyName)
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 Detail
-
getType
public Class<? extends T> getType()
Description copied from interface:Property
Returns the type of the Property. The methodsgetValue
andsetValue
must be compatible with this type: one must be able to safely cast the value returned fromgetValue
to the given type and pass any variable assignable to this type as an argument tosetValue
.- Returns:
- type of the Property
-
isReadOnly
public boolean isReadOnly()
Description copied from class:AbstractProperty
Tests if the Property is in read-only mode. In read-only mode calls to the methodsetValue
will throwReadOnlyException
and will not modify the value of the Property. Override for additional restrictions on what is considered a read-only property.- Specified by:
isReadOnly
in interfaceProperty<T>
- Overrides:
isReadOnly
in classAbstractProperty<T>
- Returns:
true
if the Property is in read-only mode,false
if it's not
-
getValue
public T 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:
getInstance()
-
setValue
public void setValue(T newValue) throws Property.ReadOnlyException
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(Object)
-
invokeSetMethod
protected void invokeSetMethod(T value)
Internal method to actually call the setter method of the wrapped property.- Parameters:
value
-
-
getGetMethods
protected List<Method> 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
public Object getInstance()
The instance used by this property- Returns:
- the instance used for fetching the property value
- Since:
- 7.7.7
-
setInstance
public void setInstance(Object instance)
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
-
-