|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.beans.BeanUtils
public class BeanUtils
Helper class for Java beans.
| Nested Class Summary | |
|---|---|
static interface |
BeanUtils.BeanConverter<FROM,TO>
Converter interface which offers a BeanUtils.BeanConverter.convert(Object) method which has to convert one bean type to another. |
| Constructor Summary | |
|---|---|
BeanUtils()
|
|
| Method Summary | ||
|---|---|---|
static BeanMethodInformation |
beanMethodInformation(Method method)
Returns a BeanMethodInformation object determined for the given Method. |
|
static Set<BeanMethodInformation> |
beanMethodInformationSet(Class<?> clazz)
Returns a set of BeanMethodInformation instances for all methods of a given Class. |
|
static
|
beanPropertyAccessor(Class<B> beanClass,
Field field)
Returns a BeanPropertyAccessor object determined for the given Field. |
|
static
|
beanPropertyAccessor(Class<B> beanClass,
Method method)
Returns a BeanPropertyAccessor object determined for the given Method. |
|
static
|
beanPropertyAccessor(Class<B> beanClass,
String propertyName)
Returns a BeanPropertyAccessor object determined for the given property name |
|
static
|
beanPropertyAccessors(Class<B> beanClass)
Returns the BeanPropertyAccessors for a given Java Bean type |
|
static
|
beanPropertyAccessorSet(Class<B> beanClass)
Returns a set of BeanPropertyAccessor instances for all Java Bean properties of the given Class |
|
static
|
cloneBean(B bean)
Clones the given JavaBean by using the standard contructor to create a new instance and then to populate all properties using copyPropertyValues(Object, Object) to the new created instance. |
|
static
|
cloneBeanUsingInstanceOfMap(B bean)
Clones the given Java bean using a Map to store all properties and providing a proxy which accesses this underlying
Map. |
|
static
|
cloneBeanUsingInstanceOfMap(B bean,
boolean underlyingMapAware)
Clones the given Java bean using a Map to store all properties and providing a proxy which accesses this underlying
Map. |
|
static
|
cloneBeanUsingNestedfMap(B bean)
Clones the given Java bean using BeanToNestedMapConverter.clone(Object) |
|
static
|
cloneBeanUsingNestedfMap(B bean,
Map<Class<?>,Class<?>> sourceTypeTodestinationTypeMap)
Clones the given Java bean using a BeanToNestedMapConverter.clone(Object). |
|
static
|
convert(FROM sourceBean,
BeanUtils.BeanConverter<FROM,TO> beanConverter)
Converts a given bean into another using a BeanUtils.BeanConverter. |
|
static
|
copyPropertyValues(S beanSource,
D beanDestination)
Copies the property values from one Java Bean to another. |
|
static
|
copyPropertyValues(S beanSource,
D beanDestination,
Collection<String> propertyNameCollection)
Copies the property values from one Java Bean to another but only for the given property names. |
|
static
|
copyPropertyValues(S beanSource,
D beanDestination,
String... propertyNames)
Copies the property values for the given property names from one Java Bean to another. |
|
static Map<String,BeanMethodInformation> |
methodNameToBeanMethodInformationMap(Class<?> type)
Determines a Map with the referenced Method.getName()s as keys and the respective
BeanMethodInformation name. |
|
static Map<String,BeanMethodInformation> |
methodNameToBeanMethodInformationMap(Method... methods)
Determines a Map with all Method.getName()s and the respective BeanMethodInformation instances. |
|
static int |
numberOfProperties(Class<?> beanClass)
Returns the number of available Java Bean properties for the given Java Bean type. |
|
static Set<String> |
propertyNameSetForMethodAccess(Class<?> clazz)
Determines the property names of a given bean class which are addressed by getter or setter. |
|
static String[] |
propertyNamesForMethodAccess(Class<?> type)
Determines the property names of a given bean class which are addressed by getter or setter. |
|
static Map<String,Set<BeanMethodInformation>> |
propertyNameToBeanMethodInformationMap(Class<?> clazz)
Determines a Map with the referenced field names as keys and a Set of BeanMethodInformation for every
field name. |
|
static Map<String,Set<BeanMethodInformation>> |
propertyNameToBeanMethodInformationMap(Method... methods)
Determines a map with the referenced field names as keys and a Set of BeanMethodInformation for every field
name. |
|
static
|
propertyNameToBeanPropertyAccessorMap(Class<B> beanClass)
Returns a map of property names and BeanPropertyAccessor instances for all Java Bean properties of the given
Class. |
|
static
|
propertyNameToBeanPropertyAccessorMap(Class<B> beanClass,
Field... fields)
Returns a map of field names and BeanPropertyAccessor instances for all Java Bean properties related to at least one
of the given Fields. |
|
static
|
propertyNameToBeanPropertyAccessorMap(Class<B> beanClass,
Method... methods)
Returns a map of field names and BeanPropertyAccessor instances for all Java Bean properties related to at least one
of the given Methods. |
|
static
|
propertyNameToBeanPropertyAnnotationMap(Class<B> beanClass,
Class<A> annotationType)
Returns a Map with all properties of a given Java Bean class and an instance of the given Annotation type if
the respective property does have one. |
|
static
|
propertyNameToBeanPropertyAnnotationSetMap(Class<B> beanClass)
Returns a Map with all property names of the given Java Bean and a Set of all available annotations for the
properties, including the field, getter and setter methods. |
|
static
|
propertyNameToBeanPropertyValueMap(B bean)
Returns a map of property names and their current values for all Java Bean properties or the given Java Bean object. |
|
static
|
propertyNameToBeanPropertyValueMap(B bean,
Collection<String> propertyNameCollection)
Returns a map of property names and their current values for the Java Bean properties determined by the given property names for the given Java Bean object. |
|
static
|
propertyNameToBeanPropertyValueMap(B bean,
String... propertyNames)
Returns a Map of property names and their current values for the Java Bean properties determined by the given
property names for the given Java Bean object. |
|
static
|
propertyTypeToBeanPropertyAccessorSetMap(Class<B> beanClass)
Returns a map of property types for all Java Bean properties of the given Class and a Set of
BeanPropertyAccessor instances for each type. |
|
static
|
propertyValueList(B bean)
Returns as List of the values of all available properties of the given JavaBean object instance. |
|
static
|
propertyValueList(B bean,
Collection<String> propertyNameCollection)
Returns an new ordered List of all property values for the given property names from the given Java Bean object |
|
static
|
propertyValueList(B bean,
String... propertyNames)
Returns an new ordered List of all property values for the given property names from the given Java Bean object |
|
static
|
transformBeanIntoMap(B bean)
Returns a new Map instance which contains the property names as keys and the values of the properties as map values. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BeanUtils()
| Method Detail |
|---|
public static <B> Map<String,Object> transformBeanIntoMap(B bean)
Map instance which contains the property names as keys and the values of the properties as map values.
Modifications to the returned map will have no impact on the original Java Bean object.
B - bean -
LinkedHashMapPropertynameMapToTypeAdapterpublic static int numberOfProperties(Class<?> beanClass)
beanClass -
public static <B> Set<BeanPropertyAccessor<B>> beanPropertyAccessorSet(Class<B> beanClass)
BeanPropertyAccessor instances for all Java Bean properties of the given Class
beanClass -
propertyNameToBeanPropertyAccessorMap(Class),
beanPropertyAccessor(Class, Field)public static <B> BeanPropertyAccessors<B> beanPropertyAccessors(Class<B> beanClass)
BeanPropertyAccessors for a given Java Bean type
B - beanClass -
public static <B> List<B> propertyValueList(B bean,
String... propertyNames)
List of all property values for the given property names from the given Java Bean object
bean - propertyNames -
public static <B> List<B> propertyValueList(B bean,
Collection<String> propertyNameCollection)
List of all property values for the given property names from the given Java Bean object
bean - propertyNameCollection -
public static <B> List<B> propertyValueList(B bean)
List of the values of all available properties of the given JavaBean object instance.
bean -
propertyValueList(Object, String...)
public static <B,A extends Annotation> Map<String,A> propertyNameToBeanPropertyAnnotationMap(Class<B> beanClass,
Class<A> annotationType)
Map with all properties of a given Java Bean class and an instance of the given Annotation type if
the respective property does have one. Otherwise the map contains a key with a null value.
beanClass - annotationType -
propertyNameToBeanPropertyAnnotationSetMap(Class)public static <B> Map<String,Set<Annotation>> propertyNameToBeanPropertyAnnotationSetMap(Class<B> beanClass)
Map with all property names of the given Java Bean and a Set of all available annotations for the
properties, including the field, getter and setter methods.
beanClass -
public static <B,V> Map<String,V> propertyNameToBeanPropertyValueMap(B bean,
String... propertyNames)
Map of property names and their current values for the Java Bean properties determined by the given
property names for the given Java Bean object. The Map will be ordered in the same way than the given property names
B - : type of the beanV - : type of the valuesbean - propertyNames -
public static <B,V> Map<String,V> propertyNameToBeanPropertyValueMap(B bean,
Collection<String> propertyNameCollection)
Map keys and values will have the same order as the given property names.
B - : type of the beanV - : type of the valuesbean - propertyNameCollection -
public static <B,V> Map<String,V> propertyNameToBeanPropertyValueMap(B bean)
B - : type of the beanV - : type of the valuesbean -
public static <B> Map<String,BeanPropertyAccessor<B>> propertyNameToBeanPropertyAccessorMap(Class<B> beanClass,
Field... fields)
BeanPropertyAccessor instances for all Java Bean properties related to at least one
of the given Fields.
B - beanClass - fields -
public static <B> Map<String,BeanPropertyAccessor<B>> propertyNameToBeanPropertyAccessorMap(Class<B> beanClass,
Method... methods)
BeanPropertyAccessor instances for all Java Bean properties related to at least one
of the given Methods.
B - beanClass - methods -
public static <B> Map<Class<?>,Set<BeanPropertyAccessor<B>>> propertyTypeToBeanPropertyAccessorSetMap(Class<B> beanClass)
Class and a Set of
BeanPropertyAccessor instances for each type.
beanClass -
beanPropertyAccessorSet(Class),
propertyNameToBeanPropertyAccessorMap(Class)public static <B> Map<String,BeanPropertyAccessor<B>> propertyNameToBeanPropertyAccessorMap(Class<B> beanClass)
BeanPropertyAccessor instances for all Java Bean properties of the given
Class. The properties are in no order.
beanClass -
beanPropertyAccessorSet(Class)
public static <B> BeanPropertyAccessor<B> beanPropertyAccessor(Class<B> beanClass,
String propertyName)
BeanPropertyAccessor object determined for the given property name
beanClass - propertyName -
beanPropertyAccessor(Class, Field),
beanPropertyAccessorSet(Class),
propertyNameToBeanPropertyAccessorMap(Class)
public static <B> BeanPropertyAccessor<B> beanPropertyAccessor(Class<B> beanClass,
Field field)
BeanPropertyAccessor object determined for the given Field.
beanClass - field -
beanPropertyAccessor(Class, Method),
beanPropertyAccessor(Class, String),
beanPropertyAccessorSet(Class),
propertyNameToBeanPropertyAccessorMap(Class)
public static <B> BeanPropertyAccessor<B> beanPropertyAccessor(Class<B> beanClass,
Method method)
BeanPropertyAccessor object determined for the given Method.
beanClass - method -
beanPropertyAccessor(Class, Field),
beanPropertyAccessorSet(Class),
propertyNameToBeanPropertyAccessorMap(Class)public static Set<BeanMethodInformation> beanMethodInformationSet(Class<?> clazz)
BeanMethodInformation instances for all methods of a given Class.
clazz -
public static Map<String,Set<BeanMethodInformation>> propertyNameToBeanMethodInformationMap(Class<?> clazz)
Map with the referenced field names as keys and a Set of BeanMethodInformation for every
field name.
clazz -
public static Map<String,BeanMethodInformation> methodNameToBeanMethodInformationMap(Class<?> type)
Map with the referenced Method.getName()s as keys and the respective
BeanMethodInformation name.
type -
public static Map<String,Set<BeanMethodInformation>> propertyNameToBeanMethodInformationMap(Method... methods)
Set of BeanMethodInformation for every field
name. The map keys are in no order.
methods -
public static Map<String,BeanMethodInformation> methodNameToBeanMethodInformationMap(Method... methods)
Map with all Method.getName()s and the respective BeanMethodInformation instances.
methods -
public static BeanMethodInformation beanMethodInformation(Method method)
BeanMethodInformation object determined for the given Method.
public static <FROM,TO> TO convert(FROM sourceBean,
BeanUtils.BeanConverter<FROM,TO> beanConverter)
BeanUtils.BeanConverter. Exceptions are catched and ignored by this method.
sourceBean - beanConverter -
public static <S,D> void copyPropertyValues(S beanSource,
D beanDestination)
S - D - beanSource - beanDestination -
public static <S,D> void copyPropertyValues(S beanSource,
D beanDestination,
String... propertyNames)
S - D - beanSource - beanDestination - propertyNames -
public static <S,D> void copyPropertyValues(S beanSource,
D beanDestination,
Collection<String> propertyNameCollection)
S - D - beanSource - beanDestination - propertyNameCollection - public static Set<String> propertyNameSetForMethodAccess(Class<?> clazz)
clazz -
SetpropertyNamesForMethodAccess(Class)public static String[] propertyNamesForMethodAccess(Class<?> type)
type -
propertyNameSetForMethodAccess(Class)public static <B> B cloneBean(B bean)
copyPropertyValues(Object, Object) to the new created instance.
bean -
public static <B> B cloneBeanUsingInstanceOfMap(B bean)
Map to store all properties and providing a proxy which accesses this underlying
Map.
bean -
public static <B> B cloneBeanUsingInstanceOfMap(B bean,
boolean underlyingMapAware)
Map to store all properties and providing a proxy which accesses this underlying
Map.
bean - underlyingMapAware -
public static <B> B cloneBeanUsingNestedfMap(B bean)
BeanToNestedMapConverter.clone(Object)
bean -
public static <B> B cloneBeanUsingNestedfMap(B bean,
Map<Class<?>,Class<?>> sourceTypeTodestinationTypeMap)
BeanToNestedMapConverter.clone(Object). Offers a Map parameter which needs
source types and destination types. For all found source types the destination types are used for instantiation. Missing
properties will just be ignored and no execpetion is thrown.
bean - sourceTypeTodestinationTypeMap -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||