Package com.sun.enterprise.util
Class BeanUtils
- java.lang.Object
-
- com.sun.enterprise.util.BeanUtils
-
public class BeanUtils extends Object
Static methods which are handy to manipulate java beans- Author:
- martinmares
-
-
Constructor Summary
Constructors Constructor Description BeanUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>beanToMap(Object bean)Loads all getters to the Map.static Collection<Method>getGetters(Object bean)static MethodgetSetter(Object bean, String attributeName)static Collection<Method>getSetters(Object bean)static voidmapToBean(Object bean, Map<String,Object> data, boolean ignoreNotExistingSetter)Sets values from map to provided bean.static StringtoAttributeName(Method m)Extract attribute name from getter or setter.
-
-
-
Method Detail
-
beanToMap
public static Map<String,Object> beanToMap(Object bean) throws InvocationTargetException
Loads all getters to the Map.- Throws:
InvocationTargetException
-
mapToBean
public static void mapToBean(Object bean, Map<String,Object> data, boolean ignoreNotExistingSetter) throws InvocationTargetException, IllegalArgumentException
Sets values from map to provided bean.- Parameters:
bean- Set to its settersdata- key is attribute name and value is value to setignoreNotExistingSetter- iffalseand data contains key which does not point to any setter then IllegalArgumentException will be thrown- Throws:
InvocationTargetExceptionIllegalArgumentException
-
getGetters
public static Collection<Method> getGetters(Object bean)
-
getSetters
public static Collection<Method> getSetters(Object bean)
-
toAttributeName
public static String toAttributeName(Method m) throws IllegalArgumentException
Extract attribute name from getter or setter.- Returns:
- IllegalArgumentException if method is not getter or setter.
- Throws:
IllegalArgumentException
-
-