|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjodd.bean.BeanUtil
Miscellaneous and useful bean utilities.
Constructor Summary | |
BeanUtil()
|
Method Summary | |
static void |
copyProperties(java.lang.Object source,
java.lang.Object destination)
Copies properties of one bean to another. |
static void |
forEachProperty(java.lang.Object bean,
PropertyCallback fepcb)
Iterrates all read properties and executes callback method on it |
static java.util.Map |
getAllProperties(java.lang.Object bean)
Returns all bean properties (getXxx()) as a Map for easier
and faster manipulation. |
static java.lang.Object |
getProperty(java.lang.Object bean,
java.lang.String name)
Gets the value from the bean paramter. |
static void |
load(java.lang.Object bean,
java.lang.Object obj)
Populates bean from given object by using a loader for given objects type. |
static void |
setAllProperties(java.lang.Object bean,
java.util.Map map)
Sets all bean properties that are defined in the map for faster work. |
static boolean |
setProperty(java.lang.Object bean,
java.lang.String name,
java.lang.Object value)
Sets JavaBean property. |
static java.lang.String |
toString(java.lang.Object o)
Creates formated string that contains names of all readable properties (getXXX() methods) and their values. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BeanUtil()
Method Detail |
public static boolean setProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value)
Note: there must *not* be more than one setXxx() with the same name. This is ok, since Java doesn't allow more than one getXxx() with the same name.
This method is about much faster then Commons.
Method doesn't throw any exception.
bean
- java beanname
- name of the property (not method, i.e. without "set" prefix)value
- new value for the property
public static void setAllProperties(java.lang.Object bean, java.util.Map map)
bean
- java bean which properties has to be setmap
- map to read fromsetProperty(java.lang.Object, java.lang.String, java.lang.Object)
,
getAllProperties(java.lang.Object)
public static java.lang.Object getProperty(java.lang.Object bean, java.lang.String name)
Method doesn't throw any exception.
bean
- java beanname
- property name
public static java.util.Map getAllProperties(java.lang.Object bean)
Map
for easier
and faster manipulation. Property names (without 'get') are keys and
property values are map values.
bean
- java bean which properties to read
Map
that contains all bean properties valuesgetProperty(java.lang.Object, java.lang.String)
,
setAllProperties(java.lang.Object, java.util.Map)
public static void copyProperties(java.lang.Object source, java.lang.Object destination)
source
- source bean, one to read properties fromdestination
- destination bean, to write properties topublic static void forEachProperty(java.lang.Object bean, PropertyCallback fepcb)
bean
- bean that will be modifiedfepcb
- modifier that will be called back for properties modificationspublic static void load(java.lang.Object bean, java.lang.Object obj)
bean
- java beanobj
- objectpublic static java.lang.String toString(java.lang.Object o)
o
- java bean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |