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 class
BeanHelper.Bean1
class
BeanHelper.Bean2
-
Constructor Summary
Constructors Constructor Description BeanHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Map
bean2Map(Object bean)
static Map
bean2MapAllGet(Object bean)
static List<String>
beanSetList(Object bean)
static String
beanToString(Object bean)
static int
copy(Map map, Object bean, boolean resetBoolean)
copy map in bean, call set[key] ( value ).static int
copy(Map map, Object bean, String keyPrefix, String keySuffix)
static void
copyBean(Object bean1, Object bean2)
copy bean1 in bean2, if method set exist in bean2.static void
extractPropertiesAsString(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 Object
getProperty(Object bean, String property)
static void
main(String[] args)
static String
replaceValueInText(String text, Object bean, String prefix, String suffix)
static void
resetBoolean(Object bean)
static Object
setProperty(Object bean, String property, Object value)
static void
storeBeanToCSV(File file, Collection<Object> beans)
void
test()
-
-
-
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:
SecurityException
IllegalArgumentException
IllegalAccessException
InvocationTargetException
-
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:
SecurityException
IllegalArgumentException
IllegalAccessException
InvocationTargetException
-
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
-
-