com.holonplatform.core.beans

## Interface BeanPropertySet<T>

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

      public interface BeanPropertySet<T>
      extends PropertySet<PathProperty<?>>

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

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.property.PropertySet

      `PropertySet.Builder<P extends Property>`

  - ### Field Summary

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

      `CONTEXT_KEY`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default 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)` Create a bean property set using default `BeanIntrospector`.
    `Class<? extends T>` | `getBeanClass()` Get the bean class to which this property set refers.
    `<PT> Optional<PathProperty<PT>>` | `getProperty(String propertyName)` Get the bean property with given `propertyName`.
    `<PT> Optional<PathProperty<PT>>` | `getProperty(String propertyName, Class<PT> type)` Get the bean property with given `propertyName` and given `type`.
    `<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.
    `default <PT> PathProperty<PT>` | `requireProperty(String propertyName)` Get the bean property with given `propertyName`.
    `default <PT> PathProperty<PT>` | `requireProperty(String propertyName, Class<PT> type)` Get the bean property with given `propertyName` and given `type`.
    `<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, contains, execute, join, of, of, of, size, stream`

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

      `forEach, iterator, spliterator`

- - ### Method Detail

    - #### getBeanClass

          Class<? extends T> getBeanClass()

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

    - #### getProperty

          <PT> Optional<PathProperty<PT>> getProperty(String propertyName)

      Get the bean property with given `propertyName`. For nested properties, the default property name hierarchy notation using `Path.PATH_HIERARCHY_SEPARATOR` as separator character is used.
      Type Parameters:
        `PT` - Property type
      Parameters:
        `propertyName` - Property name (not null)
      Returns:
        The bean property with given name, or an empty Optional if not found

    - #### getProperty

          <PT> Optional<PathProperty<PT>> getProperty(String propertyName,
                                                      Class<PT> type)

      Get the bean property with given `propertyName` and given `type`. For nested properties, the default property name hierarchy notation using `Path.PATH_HIERARCHY_SEPARATOR` as separator character is used.
      Type Parameters:
        `PT` - Property type
      Parameters:
        `propertyName` - Property name (not null)
        `type` - Property type
      Returns:
        The bean property with given name, or an empty Optional if not found
      Throws:
        `TypeMismatchException` - If the given type is not consistent with actual property type

    - #### requireProperty

          default <PT> PathProperty<PT> requireProperty(String propertyName)

      Get the bean property with given `propertyName`. For nested properties, the default property name hierarchy notation using `Path.PATH_HIERARCHY_SEPARATOR` as separator character is used.
      Type Parameters:
        `PT` - Property type
      Parameters:
        `propertyName` - Property name (not null)
      Returns:
        The bean property with given name, or an empty Optional if not found
      Throws:
        `Property.PropertyNotFoundException` - If property with given name was not found in bean property set

    - #### requireProperty

          default <PT> PathProperty<PT> requireProperty(String propertyName,
                                                        Class<PT> type)

      Get the bean property with given `propertyName` and given `type`. For nested properties, the default property name hierarchy notation using `Path.PATH_HIERARCHY_SEPARATOR` as separator character is used.
      Type Parameters:
        `PT` - Property type
      Parameters:
        `propertyName` - Property name (not null)
        `type` - Property type
      Returns:
        The bean property with given name, or an empty Optional if not found
      Throws:
        `Property.PropertyNotFoundException` - If property with given name was not found in bean property set
        `TypeMismatchException` - If the given type is not consistent with actual property type

    - #### 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

    - #### 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

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

      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 © 2017 The Holon Platform. All rights reserved.