com.holonplatform.core.property

## Interface PropertyRendererRegistry

-     public interface PropertyRendererRegistry

  A registry to register `PropertyRenderer`s bound to a condition and provide a suitable `PropertyRenderer` for a given `Property` and rendering type.

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

  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `PropertyRendererRegistry.NoSuitableRendererAvailableException` Exception thrown a suitable `PropertyRenderer` is not available for a given `Property` and rendering type

  - ### 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 PropertyRendererRegistry` | `create(boolean loadDefaults)` Create a default instance of `PropertyRendererRegistry`.
    `static PropertyRendererRegistry` | `get()` Gets the current `PropertyRendererRegistry` instance.
    `static PropertyRendererRegistry` | `getDefault()` Return the default `PropertyRendererRegistry` using default `ClassLoader`.
    `static PropertyRendererRegistry` | `getDefault(ClassLoader classLoader)` Return the default `PropertyRendererRegistry` using given `classLoader`.
    `<R,T> Optional<PropertyRenderer<R,T>>` | `getRenderer(Class<R> renderingType, Property<T> property)` Gets the `PropertyRenderer` to use with given `property` according to registered renderers for given `renderingType`.
    `<R,T> void` | `register(Predicate<Property<? extends T>> condition, PropertyRenderer<R,? super T> renderer)` Bind a `PropertyRenderer` to a property `Predicate` `condition`.

- - ### Field Detail

    - #### CONTEXT_KEY

          static final String CONTEXT_KEY

      Default `Context` resource key

  - ### Method Detail

    - #### register

          <R,T> void register(Predicate<Property<? extends T>> condition,
                              PropertyRenderer<R,? super T> renderer)

      Bind a `PropertyRenderer` to a property `Predicate` `condition`.
      Type Parameters:
        `R` - Rendering type
        `T` - Property base type
      Parameters:
        `condition` - Condition which has to be satisfied to provide the renderer (not null)
        `renderer` - PropertyRenderer to register (not null)

    - #### getRenderer

          <R,T> Optional<PropertyRenderer<R,T>> getRenderer(Class<R> renderingType,
                                                            Property<T> property)

      Gets the `PropertyRenderer` to use with given `property` according to registered renderers for given `renderingType`.
      Type Parameters:
        `R` - Rendering type
        `T` - Property base type
      Parameters:
        `renderingType` - Required rendering type (not null)
        `property` - Property to render (not null)
      Returns:
        The `PropertyRenderer` to render given property as given rendering type, or an empty Optional if a suitable renderer is not available

    - #### create

          static PropertyRendererRegistry create(boolean loadDefaults)

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

    - #### get

          static PropertyRendererRegistry get()

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

    - #### getDefault

          static PropertyRendererRegistry getDefault(ClassLoader classLoader)

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

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

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

    - #### getDefault

          static PropertyRendererRegistry getDefault()

      Return the default `PropertyRendererRegistry` using default `ClassLoader`.

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

      Returns:
        Default PropertyRendererRegistry

Copyright © 2017 The Holon Platform. All rights reserved.