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

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:
  • Constructor Details

    • 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 applies
      propertyName - dot separated nested property name
      Throws:
      IllegalArgumentException - if the property name is invalid
  • Method Details

    • getType

      public Class<? extends T> getType()
      Description copied from interface: Property
      Returns the type of the Property. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.
      Returns:
      type of the Property
    • isPropertyReadOnly

      public boolean isPropertyReadOnly()
      Description copied from class: AbstractProperty
      Tests if the Property is in read-only mode. In read-only mode calls to the method setValue will throw ReadOnlyException and will not modify the value of the Property. Override for additional restrictions on what is considered a read-only property.
      Specified by:
      isPropertyReadOnly in interface Property<T>
      Overrides:
      isPropertyReadOnly in class AbstractProperty<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:
    • 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

      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