com.holonplatform.core.property

## Interface PropertyValuePresenterRegistry

-     public interface PropertyValuePresenterRegistry

  A registry to register `PropertyValuePresenter`s bound to a condition and provide a suitable `PropertyValuePresenter`.

  The registry supports `PropertyValuePresenter`s priority declaration using `Priority` annotation on presenter class (where less priority value means higher priority order), to select and return the most suitable presenter where more than one presenter matches the condition to which is bound at registration time.

  Since:
    5.0.0

- - ### 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
    --- | ---
    `static PropertyValuePresenterRegistry` | `create(boolean loadDefaults)` Create a default instance of `PropertyValuePresenterRegistry`.
    `default <T> void` | `forProperty(Property<? extends T> property, PropertyValuePresenter<? super T> presenter)` Bind a `PropertyValuePresenter` to the given property.
    `default <T,C> void` | `forPropertyConfiguration(ConfigProperty<C> configurationProperty, C value, PropertyValuePresenter<? super T> presenter)` Bind a `PropertyValuePresenter` to the given property configuration value.
    `static PropertyValuePresenterRegistry` | `get()` Gets the current `PropertyValuePresenterRegistry` instance.
    `static PropertyValuePresenterRegistry` | `getDefault()` Return the default `PropertyValuePresenterRegistry` using default `ClassLoader`.
    `static PropertyValuePresenterRegistry` | `getDefault(ClassLoader classLoader)` Return the default `PropertyValuePresenterRegistry` using given `classLoader`.
    `<T> Optional<PropertyValuePresenter<T>>` | `getPresenter(Property<T> property)` Gets the `PropertyValuePresenter` to use with given `property` according to registered presenters.
    `<T> void` | `register(Predicate<Property<? extends T>> condition, PropertyValuePresenter<? super T> presenter)` Bind a `PropertyValuePresenter` to a property `Predicate` `condition`

- - ### Field Detail

    - #### CONTEXT_KEY

          static final String CONTEXT_KEY

      Default `Context` resource key

  - ### Method Detail

    - #### register

          <T> void register(Predicate<Property<? extends T>> condition,
                            PropertyValuePresenter<? super T> presenter)

      Bind a `PropertyValuePresenter` to a property `Predicate` `condition`
      Type Parameters:
        `T` - Property base type
      Parameters:
        `condition` - The condition which has to be satisfied to provide the presenter (not null)
        `presenter` - The PropertyPresenter to register (not null)

    - #### forProperty

          default <T> void forProperty(Property<? extends T> property,
                                       PropertyValuePresenter<? super T> presenter)

      Bind a `PropertyValuePresenter` to the given property. The presenter will be provided when the property to render is the same as the given property.
      Type Parameters:
        `T` - Property base type
      Parameters:
        `property` - The property to present (not null)
        `presenter` - The PropertyPresenter to register (not null)

    - #### forPropertyConfiguration

          default <T,C> void forPropertyConfiguration(ConfigProperty<C> configurationProperty,
                                                      C value,
                                                      PropertyValuePresenter<? super T> presenter)

      Bind a `PropertyValuePresenter` to the given property configuration value. The presenter will be provided when the property has the given `configurationProperty` and its value equals to given `value`.
      Type Parameters:
        `T` - Property base type
        `C` - Configuration property type
      Parameters:
        `configurationProperty` - The configuration property to check (not null)
        `value` - The configuration property value to check (may be null)
        `presenter` - The PropertyPresenter to register (not null)

    - #### getPresenter

          <T> Optional<PropertyValuePresenter<T>> getPresenter(Property<T> property)

      Gets the `PropertyValuePresenter` to use with given `property` according to registered presenters.
      Type Parameters:
        `T` - Property base type
      Parameters:
        `property` - Property to present
      Returns:
        PropertyValuePresenter, or an empty Optional if no presenter is available for given property

    - #### create

          static PropertyValuePresenterRegistry create(boolean loadDefaults)

      Create a default instance of `PropertyValuePresenterRegistry`.
      Parameters:
        `loadDefaults` - `true` to load default `PropertyValuePresenter`s from `META-INF/services` using `com.holonplatform.core.property.PropertyValuePresenter` files using default ClassLoader. Every default presenter will be registered using an always `true` condition.
      Returns:
        PropertyValuePresenterRegistry instance

    - #### get

          static PropertyValuePresenterRegistry get()

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

    - #### getDefault

          static PropertyValuePresenterRegistry getDefault(ClassLoader classLoader)

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

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

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

    - #### getDefault

          static PropertyValuePresenterRegistry getDefault()

      Return the default `PropertyValuePresenterRegistry` using default `ClassLoader`.

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

      Returns:
        Default PropertyValuePresenterRegistry

Copyright © 2019 The Holon Platform. All rights reserved.