Package net.solarnetwork.util
Class MapBeanProxy
java.lang.Object
net.solarnetwork.util.MapBeanProxy
- All Implemented Interfaces:
InvocationHandler
Proxy
InvocationHandler that treats keys in a Map as JavaBean
getter/setter methods.- Since:
- 1.71
- Version:
- 1.0
- Author:
- matt
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMapBeanProxy(Map<String, ?> data) Constructor.MapBeanProxy(Map<String, ?> data, boolean readOnly) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TcreateProxy(MapBeanProxy bean, Class<?>... interfaces) Create a new proxy instance.static <T> TcreateProxy(MapBeanProxy bean, ClassLoader classLoader, Class<?>... interfaces) Create a new proxy instance.getData()Get the data map.
-
Field Details
-
GETTER_REGEX
A pattern used to match a JavaBean style getter method name. -
SETTER_REGEX
A pattern used to match a JavaBean style setter method name.
-
-
Constructor Details
-
MapBeanProxy
Constructor.- Parameters:
data- the map data; a new map instance will be created if null
-
MapBeanProxy
Constructor.- Parameters:
data- the map data; a new map instance will be created if nullreadOnly- true to disallow setter method invocation to the data map
-
-
Method Details
-
createProxy
Create a new proxy instance.- Type Parameters:
T- the type to cast the result to- Parameters:
bean- the bean to proxyinterfaces- specific interfaces to implement, or null to extract all interfaces frombean- Returns:
- the proxy, which will implement all interfaces defined by
interfacesorbean
-
createProxy
Create a new proxy instance.- Type Parameters:
T- the type to cast the result to- Parameters:
bean- the bean to proxyclassLoader- the class loader to use, or null to use the class loader ofbeaninterfaces- specific interfaces to implement, or null to extract all interfaces frombean- Returns:
- the proxy, which will implement all interfaces defined by
interfacesorbean
-
invoke
- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-
getData
Get the data map.- Returns:
- the data
-