com.holonplatform.core.beans

## Interface BeanPropertySet<T>

- Type Parameters:
    `T` - Bean class to which this property set refers
  All Superinterfaces:
    BeanPropertyInspector, DataMappable, HasConfiguration<ParameterSet>, Iterable<PathProperty<?>>, PropertySet<PathProperty<?>>

      public interface BeanPropertySet<T>
      extends PropertySet<PathProperty<?>>, BeanPropertyInspector, DataMappable

  A `PropertySet` collecting and providing Java Bean property set and configuration as `PathProperty` property type elements.
  See Also:
    `BeanIntrospector`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `BeanPropertySet.Builder<T,B extends BeanPropertySet<T>>` `BeanPropertySet` builder.

  - ### Field Summary

    - ### Fields inherited from interface com.holonplatform.core.property.PropertySet

      `CONTEXT_KEY, PROPERTY_CONFIGURATION_ATTRIBUTE`

    - ### Fields inherited from interface com.holonplatform.core.DataMappable

      `DEFAULT_CONFIG_PROPERTY_PREFIX, PATH`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> BeanPropertySet<T>` | `create(Class<? extends T> beanClass)` Create a bean property set using default `BeanIntrospector`.
    `static <T> BeanPropertySet<T>` | `create(Class<? extends T> beanClass, Path<?> parentPath)` Deprecated. The root bean property path will always be a `Path.FinalPath` typed on bean class and with the bean class name as path name. Use `create(Class)` instead.
    `Class<? extends T>` | `getBeanClass()` Get the bean class to which this property set refers.
    `default Optional<String>` | `getDataPath()` Get the data model path name to which this bean property set is mapped.
    `<V> V` | `read(Path<V> path, T instance)` Read the value of the property bound to given `path` from given bean instance, using full path name to match the bean property to read.
    `default PropertyBox` | `read(PropertyBox propertyBox, T instance)` Read the property values from given bean instance into the given `PropertyBox`, using given `propertyBox` property set.
    `PropertyBox` | `read(PropertyBox propertyBox, T instance, boolean ignoreMissing)` Read the property values from given bean instance into the given `PropertyBox`, using given `propertyBox` property set.
    `<V> V` | `read(String propertyName, T instance)` Read the value of the property with given `propertyName` from given bean instance.
    `default PropertyBox` | `read(T instance)` Read the property values from given bean instance into a `PropertyBox` with this property set.
    `<P> void` | `write(Path<P> path, P value, T instance)` Write the `value` bound to given `path` to given bean instance, using full path name to match the bean property to write.
    `default T` | `write(PropertyBox propertyBox, T instance)` Write the property values contained into given `PropertyBox` into given bean instance.
    `T` | `write(PropertyBox propertyBox, T instance, boolean ignoreMissing)` Write the property values contained into given `PropertyBox` into given bean instance.
    `void` | `write(String propertyName, Object value, T instance)` Write the `value` of the property with given `propertyName` to given bean instance.

    - ### Methods inherited from interface com.holonplatform.core.property.PropertySet

      `asList, builder, builder, builderOf, contains, execute, getConfiguration, getFirstIdentifier, getIdentifiers, identifiers, join, of, of, of, size, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, iterator, spliterator`

    - ### Methods inherited from interface com.holonplatform.core.HasConfiguration

      `hasConfiguration`

    - ### Methods inherited from interface com.holonplatform.core.beans.BeanPropertyInspector

      `contains, getProperty, getProperty, getPropertyBoolean, getPropertyNumeric, getPropertyNumeric, getPropertyString, getPropertyTemporal, getPropertyTemporal, property, property, propertyBoolean, propertyNumeric, propertyNumeric, propertyString, propertyTemporal, propertyTemporal, requireProperty, requireProperty, stream`

    - ### Methods inherited from interface com.holonplatform.core.DataMappable

      `isDataMappable`

- - ### Method Detail

    - #### getBeanClass

          Class<? extends T> getBeanClass()

      Get the bean class to which this property set refers.
      Returns:
        the bean class

    - #### read

          <V> V read(String propertyName,
                     T instance)

      Read the value of the property with given `propertyName` from given bean instance.
      Type Parameters:
        `V` - Property and result type
      Parameters:
        `propertyName` - Name of the property to read (not null)
        `instance` - Bean instance from which to read the property value (not null)
      Returns:
        The property value
      Throws:
        `Property.PropertyNotFoundException` - If a property with given name is not found in this property set
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If actual property type and expected type mismatch

    - #### read

          <V> V read(Path<V> path,
                     T instance)

      Read the value of the property bound to given `path` from given bean instance, using full path name to match the bean property to read.
      Type Parameters:
        `V` - Path and value type
      Parameters:
        `path` - Property path to read (not null)
        `instance` - Bean instance from which to read the property value (not null)
      Returns:
        The property value
      Throws:
        `Property.PropertyNotFoundException` - If a property wich corresponds to given path name is not found in this property set
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If actual property type and expected type mismatch

    - #### write

          void write(String propertyName,
                     Object value,
                     T instance)

      Write the `value` of the property with given `propertyName` to given bean instance.
      Parameters:
        `propertyName` - Name of the property to write (not null)
        `value` - Value to write (may be null)
        `instance` - Bean instance to which to write the property value
      Throws:
        `Property.PropertyNotFoundException` - If a property with given name is not found in this property set
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If actual property type and expected type mismatch

    - #### write

          <P> void write(Path<P> path,
                         P value,
                         T instance)

      Write the `value` bound to given `path` to given bean instance, using full path name to match the bean property to write.
      Type Parameters:
        `P` - Path and value type
      Parameters:
        `path` - Property path to write (not null)
        `value` - Value to write (may be null)
        `instance` - Bean instance to which to write the property value
      Throws:
        `Property.PropertyNotFoundException` - If a property wich corresponds to given path name is not found in this property set
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If actual property type and expected type mismatch

    - #### read

          PropertyBox read(PropertyBox propertyBox,
                           T instance,
                           boolean ignoreMissing)

      Read the property values from given bean instance into the given `PropertyBox`, using given `propertyBox` property set.

      The matching between the PropertyBox properties and the bean properties is performed by property name, so only the PropertyBox properties which implements `Path` will be taken into account, using `Path.getName()` as property name.

      Any `PropertyValueConverter` will be applied to read values from bean data model.

      Parameters:
        `propertyBox` - PropertyBox into which to write the property values (not null)
        `instance` - Bean instance from which read the property values (not null)
        `ignoreMissing` - `true` to ignore properties of the PropertyBox property set which are not present as bean property. If `false`, when a property of the PropertyBox property set does not match with any of the bean properties, a `Property.PropertyNotFoundException` is thrown.
      Returns:
        The updated PropertyBox
      Throws:
        `Property.PropertyNotFoundException` - If `ignoreMissing` is `false` and a property of the PropertyBox property set does not match with any of the bean properties
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If the bean property type and the PropertyBox property type mismatch for a property
        `Validator.ValidationException` - If not `PropertyBox.isInvalidAllowed()` for given property box and one of the property values validation failed

    - #### read

          default PropertyBox read(PropertyBox propertyBox,
                                   T instance)

      Read the property values from given bean instance into the given `PropertyBox`, using given `propertyBox` property set.

      The matching between the PropertyBox properties and the bean properties is performed by property name, so only the PropertyBox properties which implements `Path` will be taken into account, using `Path.getName()` as property name.

      Any `PropertyValueConverter` will be applied to read values from bean data model.

      Parameters:
        `propertyBox` - PropertyBox into which to write the property values (not null)
        `instance` - Bean instance from which read the property values (not null)
      Returns:
        The updated PropertyBox
      Throws:
        `Property.PropertyNotFoundException` - If a property of the PropertyBox property set does not match with any of the bean properties
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If the bean property type and the PropertyBox property type mismatch for a property
        `Validator.ValidationException` - If not `PropertyBox.isInvalidAllowed()` for given property box and one of the property values validation failed

    - #### read

          default PropertyBox read(T instance)

      Read the property values from given bean instance into a `PropertyBox` with this property set.

      By default, the created PropertyBox allows invalid values, so no property value validation is performed.

      Any `PropertyValueConverter` will be applied to read values from bean data model.

      Parameters:
        `instance` - Bean instance from which read the property values (not null)
      Returns:
        The PropertyBox containing the property values read from the given bean instance
      Throws:
        `Property.PropertyAccessException` - Error accessing bean properties

    - #### write

          T write(PropertyBox propertyBox,
                  T instance,
                  boolean ignoreMissing)

      Write the property values contained into given `PropertyBox` into given bean instance.

      The matching between the PropertyBox properties and the bean properties is performed by property name, so only the PropertyBox properties which implements `PathProperty` will be taken into account, using `Path.getName()` as property name.

      Any `PropertyValueConverter` will be applied to write values to bean data model.

      Parameters:
        `propertyBox` - PropertyBox from which read the property values (not null)
        `instance` - Bean instance to which to write the property values (not null)
        `ignoreMissing` - `true` to ignore properties of the PropertyBox property set which are not present as bean property. If `false`, when a property of the PropertyBox property set does not match with any of the bean properties, a `Property.PropertyNotFoundException` is thrown.
      Returns:
        The updated bean instance
      Throws:
        `Property.PropertyNotFoundException` - If `ignoreMissing` is `false` and a property of the PropertyBox property set does not match with any of the bean properties
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If the bean property type and the PropertyBox property type mismatch for a property

    - #### write

          default T write(PropertyBox propertyBox,
                          T instance)

      Write the property values contained into given `PropertyBox` into given bean instance.

      The matching between the PropertyBox properties and the bean properties is performed by property name, so only the PropertyBox properties which implements `PathProperty` will be taken into account, using `Path.getName()` as property name.

      Any `PropertyValueConverter` will be applied to write values to bean data model.

      Parameters:
        `propertyBox` - PropertyBox from which read the property values (not null)
        `instance` - Bean instance to which to write the property values (not null)
      Returns:
        The updated bean instance
      Throws:
        `Property.PropertyNotFoundException` - If a property of the PropertyBox property set does not match with any of the bean properties
        `Property.PropertyAccessException` - Error accessing bean properties
        `TypeMismatchException` - If the bean property type and the PropertyBox property type mismatch for a property

    - #### getDataPath

          default Optional<String> getDataPath()

      Get the data model path name to which this bean property set is mapped.

      If the `DataMappable.PATH` configuration property is present, the property value is returned. Otherwise, the simple bean class name is returned.

      The `DataPath` annotation can be used on bean class to declare the data path at bean introspection time.

      Specified by:
        `getDataPath` in interface `DataMappable`
      Returns:
        The data model path name

    - #### create

          static <T> BeanPropertySet<T> create(Class<? extends T> beanClass)

      Create a bean property set using default `BeanIntrospector`.
      Type Parameters:
        `T` - Bean type
      Parameters:
        `beanClass` - Bean class for which to create the property set (not null)
      Returns:
        `PropertySet` of the properties detected from given bean class

    - #### create

          @Deprecated
          static <T> BeanPropertySet<T> create(Class<? extends T> beanClass,
                                                            Path<?> parentPath)

      Deprecated. The root bean property path will always be a `Path.FinalPath` typed on bean class and with the bean class name as path name. Use `create(Class)` instead.
      Create a bean property set using default `BeanIntrospector`. If a `parentPath` is specified, it will be setted as bean root properties parent path.
      Type Parameters:
        `T` - Bean type
      Parameters:
        `beanClass` - Bean class for which to create the property set (not null)
        `parentPath` - Optional parent path to set as bean root properties parent path
      Returns:
        `PropertySet` of the properties detected from given bean class

Copyright © 2019 The Holon Platform. All rights reserved.