Package net.solarnetwork.support
Class CloningPropertyEditorRegistrar
java.lang.Object
net.solarnetwork.support.CloningPropertyEditorRegistrar
- All Implemented Interfaces:
org.springframework.beans.PropertyEditorRegistrar
public class CloningPropertyEditorRegistrar
extends Object
implements org.springframework.beans.PropertyEditorRegistrar
PropertyEditorRegistrar implementation that creates new PropertyEditor
instances by cloning the ones configured on this class.
This implementation makes it easy to cofnigure PropertyEditors that are wired
up to Spring components but need to be used in a thread-safe manner. Each
PropertyEditor must provide a no-argument clone() method to
create fully-configured copy of itself.
The configurable properties of this class are:
- propertyEditors
- Map of property names to associated PropertyEditor instances.
- classEditors
- Map of Class objects to associated PropertyEditor instances.
- lenient
- If true (the default) then if a configured PropertyEditor does
not provide a public
clone()method, this will configure the PropertyEditor as-is, without creating a new copy. If false then a RuntimeException will be thrown if this situation is encountered.
- Version:
- 1.0
- Author:
- matt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMap<Class<?>,PropertyEditor> booleanvoidregisterCustomEditors(org.springframework.beans.PropertyEditorRegistry registry) voidsetClassEditors(Map<Class<?>, PropertyEditor> classEditors) voidsetLenient(boolean lenient) voidsetPropertyEditor(Class<?> clazz, PropertyEditor editor) Set aPropertyEditorfor a specific Class.voidsetPropertyEditor(String key, PropertyEditor editor) Set aPropertyEditorfor a specific key.voidsetPropertyEditors(Map<String, PropertyEditor> propertyEditors)
-
Constructor Details
-
CloningPropertyEditorRegistrar
public CloningPropertyEditorRegistrar()
-
-
Method Details
-
registerCustomEditors
public void registerCustomEditors(org.springframework.beans.PropertyEditorRegistry registry) - Specified by:
registerCustomEditorsin interfaceorg.springframework.beans.PropertyEditorRegistrar
-
setPropertyEditor
Set aPropertyEditorfor a specific key.- Parameters:
key- the key (property name)editor- the associated editor
-
setPropertyEditor
Set aPropertyEditorfor a specific Class.- Parameters:
clazz- the Classeditor- the associated editor
-
getPropertyEditors
- Returns:
- the propertyEditors
-
setPropertyEditors
- Parameters:
propertyEditors- the propertyEditors to set
-
isLenient
public boolean isLenient()- Returns:
- the lenient
-
setLenient
public void setLenient(boolean lenient) - Parameters:
lenient- the lenient to set
-
getClassEditors
- Returns:
- the classEditors
-
setClassEditors
- Parameters:
classEditors- the classEditors to set
-