public interface PropertyRendererRegistry
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.
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 |
Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT_KEY
Default
Context resource key |
Modifier and Type | Method and Description |
---|---|
static PropertyRendererRegistry |
create(boolean loadDefaults)
Create a default instance of
PropertyRendererRegistry . |
default <R,T> void |
forProperty(Property<? extends T> property,
PropertyRenderer<R,T> renderer)
Bind a
PropertyRenderer to the given property. |
default <R,T,C> void |
forPropertyConfiguration(ConfigProperty<C> configurationProperty,
C value,
PropertyRenderer<R,T> renderer)
Bind a
PropertyRenderer to the given property configuration value. |
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<? extends 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,T> renderer)
|
<R,T> void register(Predicate<Property<? extends T>> condition, PropertyRenderer<R,T> renderer)
R
- Rendering typeT
- Property base typecondition
- The condition which has to be satisfied to provide the renderer (not null)renderer
- The PropertyRenderer to register (not null)default <R,T> void forProperty(Property<? extends T> property, PropertyRenderer<R,T> renderer)
PropertyRenderer
to the given property. The renderer will be provided when the property to render
is the same as the given property.R
- Rendering typeT
- Property base typeproperty
- The property to render (not null)renderer
- The PropertyRenderer to register (not null)default <R,T,C> void forPropertyConfiguration(ConfigProperty<C> configurationProperty, C value, PropertyRenderer<R,T> renderer)
PropertyRenderer
to the given property configuration value. The renderer will be provided when the
property has the given configurationProperty
and its value equals to given value
.R
- Rendering typeT
- Property base typeC
- Configuration property typeconfigurationProperty
- The configuration property to check (not null)value
- The configuration property value to check (may be null)renderer
- The PropertyRenderer to register (not null)<R,T> Optional<PropertyRenderer<R,T>> getRenderer(Class<R> renderingType, Property<? extends T> property)
PropertyRenderer
to use with given property
according to registered renderers for
given renderingType
.R
- Rendering typeT
- Property base typerenderingType
- Required rendering type (not null)property
- Property to render (not null)PropertyRenderer
to render given property as given rendering type, or an empty Optional if a
suitable renderer is not availablestatic PropertyRendererRegistry create(boolean loadDefaults)
PropertyRendererRegistry
.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.static PropertyRendererRegistry get()
PropertyRendererRegistry
instance.Context
-bound PropertyRendererRegistry instance, if available using CONTEXT_KEY
as
context key, or the default instance for the default ClassLoader obtained through getDefault()
.static PropertyRendererRegistry getDefault(ClassLoader classLoader)
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.
classLoader
- ClassLoader to usestatic PropertyRendererRegistry getDefault()
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.
Copyright © 2019 The Holon Platform. All rights reserved.