Package org.sqlproc.engine.plugin
Class DefaultBeanUtilsPlugin
java.lang.Object
org.sqlproc.engine.plugin.DefaultBeanUtilsPlugin
- All Implemented Interfaces:
BeanUtilsPlugin
Standard bean utilities implementation.
- Author:
- Vladimir Hudec
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.sqlproc.engine.plugin.BeanUtilsPlugin
BeanUtilsPlugin.GetterType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConcurrentHashMap<String, Constructor<?>> protected ConcurrentHashMap<String, PropertyDescriptor[]> protected ConcurrentHashMap<String, Method> protected ConcurrentHashMap<String, Method> protected ConcurrentHashMap<String, Method> (package private) final org.slf4j.LoggerThe internal slf4j logger.protected ConcurrentHashMap<String, Method> protected ConcurrentHashMap<String, Class<?>[]> protected ConcurrentHashMap<String, Method> protected ConcurrentHashMap<String, BeanUtilsPlugin.GetterType> protected ConcurrentHashMap<String, Class<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final booleanareTheSameParameters(Class<?> methodParameterType, Class<?> parameterType) protected StringattrTypes2String(Class<?>... attrTypes) booleancheckAttribute(SqlRuntimeContext runtimeCtx, Object bean, String attrName) Checks the attribute getter method existence.booleancheckMethod(SqlRuntimeContext runtimeCtx, Class<?> clazz, String methodName, Class<?>... argTypes) Checks the class method existence.booleancheckMethod(SqlRuntimeContext runtimeCtx, Object bean, String methodName, Object... args) Checks the bean method existence.protected StringgetAttribute(SqlRuntimeContext runtimeCtx, Object bean, String attrName) Returns the value of the specified simple attribute of the specified bean.protected PropertyDescriptorgetAttributeDescriptor(Class<?> clazz, String attrName) Class<?>[]getAttributeParameterizedTypes(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName) Returns the Java parameterized type info for the attribute, if there is one.Class<?> getAttributeType(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName) Returns the Java type info for the attribute, if there is one.protected PropertyDescriptor[]getDescriptors(Class<?> clazz) Class<?> getEnumToClass(SqlRuntimeContext runtimeCtx, Class<?> clazz) Returns the bean enumeration type.getEnumToValue(SqlRuntimeContext runtimeCtx, Object bean) Returns the bean enumeration value.protected MethodgetGetter(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName, boolean onlyCheck) getGetterType(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName) Returns the attribute getter method types, if there is one.getGetterType(SqlRuntimeContext runtimeCtx, Object bean, String attrName) Returns the attribute getter method types, if there is one.getInstance(SqlRuntimeContext runtimeCtx, Class<?> clazz) Returns the new class instanceprotected Constructor<?> getInstanceConstructor(SqlRuntimeContext runtimeCtx, Class<?> clazz) protected MethodgetInterfaceMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) protected Methodprotected Methodprotected Class<?> getPrimitiveWrapper(Class<?> primitiveType) protected MethodgetSetter(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName, boolean onlyCheck, Class<?>... attrTypes) protected MethodgetSetter(SqlRuntimeContext runtimeCtx, Object bean, String attrName, boolean onlyCheck, Class<?>... attrTypes) protected MethodgetSuperclassMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) getValueToEnum(SqlRuntimeContext runtimeCtx, Class<?> clazz, Object val) Returns the enumeration instance for the enumeration valueprotected ObjectinvokeMethod(SqlRuntimeContext runtimeCtx, Class<?> clazz, Object bean, String methodName, Object... args) invokeMethod(SqlRuntimeContext runtimeCtx, Class<?> clazz, String methodName, Object... args) Invokes the class method with the specified name and parameters.protected ObjectinvokeMethod(SqlRuntimeContext runtimeCtx, Object bean, Method method, Object... args) invokeMethod(SqlRuntimeContext runtimeCtx, Object bean, String methodName, Object... args) Invokes the bean method with the specified name and parameters.voidsetAttribute(SqlRuntimeContext runtimeCtx, Object bean, String attrName, Object attrValue) Sets the value of the specified simple attribute of the specified bean.booleansimpleSetAttribute(SqlRuntimeContext runtimeCtx, Object bean, String attrName, Object attrValue, Class<?>... attrTypes) Sets the value of the specified simple attribute of the specified bean, if there is one.protected Object[]protected Class<?>[]toParameterTypes(Object arg) protected Class<?>[]toParameterTypes(Object[] args)
-
Field Details
-
constructors
-
descriptors
-
types
-
parameterizedTypes
-
getters
-
typeGetters
-
setters
-
methods
-
enumsIn
-
enumsOut
-
logger
final org.slf4j.Logger loggerThe internal slf4j logger.
-
-
Constructor Details
-
DefaultBeanUtilsPlugin
public DefaultBeanUtilsPlugin()
-
-
Method Details
-
getInstanceConstructor
-
getInstance
Returns the new class instance- Specified by:
getInstancein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class to be constructed- Returns:
- the new class instance. Null in the case of any error.
-
getDescriptors
-
getAttributeDescriptor
-
getAttributeType
Description copied from interface:BeanUtilsPluginReturns the Java type info for the attribute, if there is one.- Specified by:
getAttributeTypein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class for which the attribute type is requestedattrName- the name of the attribute which type is requested- Returns:
- the object that represents the Java type info. Null in the case there's no such attribute.
-
getAttributeParameterizedTypes
public Class<?>[] getAttributeParameterizedTypes(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName) Description copied from interface:BeanUtilsPluginReturns the Java parameterized type info for the attribute, if there is one.- Specified by:
getAttributeParameterizedTypesin interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class for which the attribute type is requestedattrName- the name of the attribute which type is requested- Returns:
- the object that represents the Java parameterized type info. Null in the case there's no such attribute.
-
getGetter
protected Method getGetter(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName, boolean onlyCheck) -
getGetterType
public BeanUtilsPlugin.GetterType getGetterType(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName) Returns the attribute getter method types, if there is one.- Specified by:
getGetterTypein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class for which the getter is requestedattrName- the name of the attribute which getter is requested- Returns:
- The method that should be used to read the property value. Null in the case there's no such attribute's getter.
-
getGetterType
public BeanUtilsPlugin.GetterType getGetterType(SqlRuntimeContext runtimeCtx, Object bean, String attrName) Returns the attribute getter method types, if there is one.- Specified by:
getGetterTypein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean for which the getter is requestedattrName- the name of the attribute which getter is requested- Returns:
- The getter method types that should be used to read the property value. Null in the case there's no such attribute's getter.
-
checkAttribute
Checks the attribute getter method existence.- Specified by:
checkAttributein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean for which the getter is checkedattrName- the name of the attribute which getter is checked- Returns:
- True if there's the attribute getter method
-
getAttribute
public Object getAttribute(SqlRuntimeContext runtimeCtx, Object bean, String attrName) throws SqlRuntimeException Returns the value of the specified simple attribute of the specified bean.- Specified by:
getAttributein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean for which the attribute value is requestedattrName- the name of the attribute which value is requested- Returns:
- the attribute value
- Throws:
SqlRuntimeException- in the case of any error
-
getSetter
protected Method getSetter(SqlRuntimeContext runtimeCtx, Class<?> clazz, String attrName, boolean onlyCheck, Class<?>... attrTypes) -
getSetter
protected Method getSetter(SqlRuntimeContext runtimeCtx, Object bean, String attrName, boolean onlyCheck, Class<?>... attrTypes) -
simpleSetAttribute
public boolean simpleSetAttribute(SqlRuntimeContext runtimeCtx, Object bean, String attrName, Object attrValue, Class<?>... attrTypes) Sets the value of the specified simple attribute of the specified bean, if there is one.- Specified by:
simpleSetAttributein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean for which the attribute value is to be modifiedattrName- the name of the attribute to be modifiedattrValue- the value to which the attribute should be setattrTypes- the possible attribute types- Returns:
- True if the attribute was successfully modified
-
setAttribute
public void setAttribute(SqlRuntimeContext runtimeCtx, Object bean, String attrName, Object attrValue) throws SqlRuntimeException Sets the value of the specified simple attribute of the specified bean.- Specified by:
setAttributein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean for which the attribute value is to be modifiedattrName- the name of the attribute to be modifiedattrValue- the value to which the attribute should be set- Throws:
SqlRuntimeException- in the case of any error
-
getMethod
-
getInterfaceMethod
-
getSuperclassMethod
-
getMethod
-
areTheSameParameters
-
getPrimitiveWrapper
-
invokeMethod
protected Object invokeMethod(SqlRuntimeContext runtimeCtx, Object bean, Method method, Object... args) -
checkMethod
public boolean checkMethod(SqlRuntimeContext runtimeCtx, Class<?> clazz, String methodName, Class<?>... argTypes) Checks the class method existence.- Specified by:
checkMethodin interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class for which the method existence is checkedmethodName- the name of the method to be checkedargTypes- the method parameters types- Returns:
- True if there's such a method
-
checkMethod
public boolean checkMethod(SqlRuntimeContext runtimeCtx, Object bean, String methodName, Object... args) Checks the bean method existence.- Specified by:
checkMethodin interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean for which the method existence is checkedmethodName- the name of the method to be checkedargs- the method parameters- Returns:
- True if there's such a method
-
invokeMethod
public Object invokeMethod(SqlRuntimeContext runtimeCtx, Class<?> clazz, String methodName, Object... args) throws SqlRuntimeException Invokes the class method with the specified name and parameters. The method can be a static one.- Specified by:
invokeMethodin interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class which method is going to be invokedmethodName- the requested method nameargs- the method parameters- Returns:
- the result of the method invocation
- Throws:
SqlRuntimeException- in the case of any error
-
invokeMethod
public Object invokeMethod(SqlRuntimeContext runtimeCtx, Object bean, String methodName, Object... args) throws SqlRuntimeException Invokes the bean method with the specified name and parameters.- Specified by:
invokeMethodin interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean which method is going to be invokedmethodName- the requested method nameargs- the method parameters- Returns:
- the result of the method invocation
- Throws:
SqlRuntimeException- in the case of any error
-
invokeMethod
protected Object invokeMethod(SqlRuntimeContext runtimeCtx, Class<?> clazz, Object bean, String methodName, Object... args) throws SqlRuntimeException - Throws:
SqlRuntimeException
-
getEnumToValue
Returns the bean enumeration value.- Specified by:
getEnumToValuein interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextbean- the bean of the enumeration type- Returns:
- the enumeration value. Null in the case of any error.
-
getEnumToClass
Returns the bean enumeration type.- Specified by:
getEnumToClassin interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class of the enumeration type- Returns:
- the enumeration type. Null in the case of any error.
-
getValueToEnum
Returns the enumeration instance for the enumeration value- Specified by:
getValueToEnumin interfaceBeanUtilsPlugin- Parameters:
runtimeCtx- the public runtime contextclazz- the class of the enumeration typeval- the enumeration value- Returns:
- the enumeration instance. Null in the case of any error.
-
attrTypes2String
-
toArray
-
toParameterTypes
-
toParameterTypes
-
debugInfo
-