com.holonplatform.core.beans

## Interface BeanIntrospector

-     public interface BeanIntrospector

  Provides functionalities to introspect Java Beans and obtain informations about bean properties, methods and configuration.
  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `BeanIntrospector.BeanIntrospectionException` Exception thrown for bean introspection failures.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONTEXT_KEY` Default `Context` resource key

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBeanPropertyPostProcessor(BeanPropertyPostProcessor beanPropertyPostProcessor)` Adds a `BeanPropertyPostProcessor` to handle `BeanProperty` configuration during introspection.
    `boolean` | `clearCache()` If caching is enabled and supported, clear current introspection cache.
    `static BeanIntrospector` | `get()` Gets the current `BeanIntrospector` instance.
    `static BeanIntrospector` | `getDefault()` Return the default `BeanIntrospector` using default `ClassLoader`.
    `static BeanIntrospector` | `getDefault(ClassLoader classLoader)` Return the default `BeanIntrospector` using given `classLoader`.
    `default <T> BeanPropertySet<T>` | `getPropertySet(Class<? extends T> beanClass)` Introspect given Java Bean `beanClass` and provides a `BeanPropertySet` to learn about bean properties and configuration.
    `<T> BeanPropertySet<T>` | `getPropertySet(Class<? extends T> beanClass, Path<?> parentPath)` Introspect given Java Bean `beanClass` and provides a `BeanPropertySet` to learn about bean properties and configuration.
    `default <T> PropertyBox` | `read(PropertyBox propertyBox, T instance)` Read the property values from given bean instance into the given `PropertyBox`, using given `propertyBox` property set.
    `default <T> 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.
    `void` | `removeBeanPropertyPostProcessor(BeanPropertyPostProcessor beanPropertyPostProcessor)` Removes a `BeanPropertyPostProcessor`.
    `default <T> T` | `write(PropertyBox propertyBox, T instance)` Write the property values contained into given `PropertyBox` into given bean instance.
    `default <T> T` | `write(PropertyBox propertyBox, T instance, boolean ignoreMissing)` Write the property values contained into given `PropertyBox` into given bean instance.

- - ### Field Detail

    - #### CONTEXT_KEY

          static final String CONTEXT_KEY

      Default `Context` resource key

  - ### Method Detail

    - #### getPropertySet

          default <T> BeanPropertySet<T> getPropertySet(Class<? extends T> beanClass)

      Introspect given Java Bean `beanClass` and provides a `BeanPropertySet` to learn about bean properties and configuration.
      Type Parameters:
        `T` - Bean class type
      Parameters:
        `beanClass` - Bean class to introspect (not null)
      Returns:
        A `BeanPropertySet` describing the target bean properties and configuration
      Throws:
        `BeanIntrospector.BeanIntrospectionException` - If an exception occurs during introspection

    - #### getPropertySet

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

      Introspect given Java Bean `beanClass` and provides a `BeanPropertySet` to learn about bean properties and configuration. If a `parentPath` is specified, it will be setted as bean root properties parent path.
      Type Parameters:
        `T` - Bean class type
      Parameters:
        `beanClass` - Bean class to introspect (not null)
        `parentPath` - Optional parent path to set as bean root properties parent path
      Returns:
        A `BeanPropertySet` describing the target bean properties and configuration
      Throws:
        `BeanIntrospector.BeanIntrospectionException` - If an exception occurs during introspection

    - #### read

          default <T> 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.

      Type Parameters:
        `T` - Bean type
      Parameters:
        `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.
        `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 `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 <T> 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.

      Type Parameters:
        `T` - Bean type
      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

    - #### write

          default <T> 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 `Path` will be taken into account, using `Path.getName()` as property name.

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

      Type Parameters:
        `T` - Bean type
      Parameters:
        `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.
        `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 `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> 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 `Path` will be taken into account, using `Path.getName()` as property name.

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

      Type Parameters:
        `T` - Bean type
      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

    - #### addBeanPropertyPostProcessor

          void addBeanPropertyPostProcessor(BeanPropertyPostProcessor beanPropertyPostProcessor)

      Adds a `BeanPropertyPostProcessor` to handle `BeanProperty` configuration during introspection.
      Parameters:
        `beanPropertyPostProcessor` - BeanPropertyPostProcessor to add (not null)

    - #### removeBeanPropertyPostProcessor

          void removeBeanPropertyPostProcessor(BeanPropertyPostProcessor beanPropertyPostProcessor)

      Removes a `BeanPropertyPostProcessor`.
      Parameters:
        `beanPropertyPostProcessor` - BeanPropertyPostProcessor to remove (not null)

    - #### clearCache

          boolean clearCache()

      If caching is enabled and supported, clear current introspection cache.
      Returns:
        `true` if caching is supported and was cleared

    - #### get

          static BeanIntrospector get()

      Gets the current `BeanIntrospector` instance.
      Returns:
        The `Context`-bound BeanIntrospector instance, if available using `CONTEXT_KEY` as context key, or the default instance for the default ClassLoader obtained through `getDefault()`.

    - #### getDefault

          static BeanIntrospector getDefault(ClassLoader classLoader)

      Return the default `BeanIntrospector` using given `classLoader`.

      The default introspector is inited loading `BeanPropertyPostProcessor`s using fully qualified name of its implementation class name to a `com.holonplatform.core.beans.BeanPropertyPostProcessor` file in the `META-INF/services` directory.

      Parameters:
        `classLoader` - ClassLoader to use
      Returns:
        Default BeanIntrospector

    - #### getDefault

          static BeanIntrospector getDefault()

      Return the default `BeanIntrospector` using default `ClassLoader`.

      The default introspector is inited loading `BeanPropertyPostProcessor`s using fully qualified name of its implementation class name to a `com.holonplatform.core.beans.BeanPropertyPostProcessor` file in the `META-INF/services` directory.

      Returns:
        Default BeanIntrospector

Copyright © 2017 The Holon Platform. All rights reserved.