Package org.javlo.helper
Class BeanHelper
- java.lang.Object
-
- org.javlo.helper.BeanHelper
-
public class BeanHelper extends Object
- Author:
- pvandermaesen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBeanHelper.Bean1classBeanHelper.Bean2
-
Constructor Summary
Constructors Constructor Description BeanHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Mapbean2Map(Object bean)static Mapbean2MapAllGet(Object bean)static List<String>beanSetList(Object bean)static StringbeanToString(Object bean)static intcopy(Map map, Object bean, boolean resetBoolean)copy map in bean, call set[key] ( value ).static intcopy(Map map, Object bean, String keyPrefix, String keySuffix)static voidcopyBean(Object bean1, Object bean2)copy bean1 in bean2, if method set exist in bean2.static voidextractPropertiesAsString(Map<String,Object> out, Object bean, String... propertyNames)static String[]getAllLabels(Object bean)static String[]getAllLabelsSorted(Object bean)sort label by buisness importance, start with, login, email, firstName, lastNamestatic Object[]getAllValues(Object bean)static ObjectgetProperty(Object bean, String property)static voidmain(String[] args)static StringreplaceValueInText(String text, Object bean, String prefix, String suffix)static voidresetBoolean(Object bean)static ObjectsetProperty(Object bean, String property, Object value)static voidstoreBeanToCSV(File file, Collection<Object> beans)voidtest()
-
-
-
Method Detail
-
bean2Map
public static Map bean2Map(Object bean) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
bean2MapAllGet
public static Map bean2MapAllGet(Object bean) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
beanSetList
public static List<String> beanSetList(Object bean) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
copy
public static int copy(Map map, Object bean, String keyPrefix, String keySuffix) throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
resetBoolean
public static void resetBoolean(Object bean) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
-
copy
public static int copy(Map map, Object bean, boolean resetBoolean) throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
copy map in bean, call set[key] ( value ).- Parameters:
a- generic mapbean- a class with set and get method.- Returns:
- the number of key found in bean without set equivalent method in bean.
- Throws:
SecurityExceptionIllegalArgumentExceptionIllegalAccessExceptionInvocationTargetException
-
extractPropertiesAsString
public static void extractPropertiesAsString(Map<String,Object> out, Object bean, String... propertyNames)
-
copyBean
public static void copyBean(Object bean1, Object bean2) throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
copy bean1 in bean2, if method set exist in bean2.- Parameters:
bean1- a class with set and get method.bean2- a class with set and get method.- Throws:
SecurityExceptionIllegalArgumentExceptionIllegalAccessExceptionInvocationTargetException
-
getAllLabelsSorted
public static String[] getAllLabelsSorted(Object bean)
sort label by buisness importance, start with, login, email, firstName, lastName- Parameters:
bean-- Returns:
-
storeBeanToCSV
public static void storeBeanToCSV(File file, Collection<Object> beans) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException
-
main
public static void main(String[] args)
-
test
public void test() throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
-