org.base.apps.beans.util
Class BeanUtil

java.lang.Object
  extended by org.base.apps.beans.util.BeanUtil

public class BeanUtil
extends Object

Utility class for bean-related functionality.

Author:
Kevan Simpson

Method Summary
static BeanInfo getBeanInfo(Class<?> beanClass)
          Returns the BeanInfo for the given class.
static BeanInfo getBeanInfo(Object bean)
          Returns the BeanInfo for the given bean.
static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass)
          Returns the property descriptors for the given class.
static PropertyDescriptor[] getPropertyDescriptors(Object bean)
          Returns the property descriptors for the given bean.
static boolean isDeprecated(Method read, Method write)
          Returns true if either the given accessor or mutator has been annoted with Deprecated.
static Map<String,PropertyDescriptor> loadBoundDescriptors(Object bean, boolean excludeReadOnly)
          Loads bound properties, those with getters and setters, from the given bean.
static Map<String,PropertyDescriptor> loadDescriptors(Class<?> clz)
          Extracts all PropertyDescriptors from the specified class and returns them mapped by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBeanInfo

public static BeanInfo getBeanInfo(Class<?> beanClass)
Returns the BeanInfo for the given class.

Parameters:
beanClass - The given class.
Returns:
The class' BeanInfo.
Throws:
IllegalArgumentException - if the given class is null.

getBeanInfo

public static BeanInfo getBeanInfo(Object bean)
Returns the BeanInfo for the given bean.

Parameters:
bean - The given bean.
Returns:
The bean's BeanInfo.
Throws:
IllegalArgumentException - if the given bean is null.

getPropertyDescriptors

public static PropertyDescriptor[] getPropertyDescriptors(Class<?> beanClass)
Returns the property descriptors for the given class.

Parameters:
beanClass - The given class.
Returns:
The class' property descriptors.
Throws:
IllegalArgumentException - if the given class is null.

getPropertyDescriptors

public static PropertyDescriptor[] getPropertyDescriptors(Object bean)
Returns the property descriptors for the given bean.

Parameters:
bean - The given bean.
Returns:
The bean's property descriptors.
Throws:
IllegalArgumentException - if the given bean is null.

loadDescriptors

public static Map<String,PropertyDescriptor> loadDescriptors(Class<?> clz)
Extracts all PropertyDescriptors from the specified class and returns them mapped by name. Any class from the JDK will be ignored and return an empty map. More specifically, if the given class resides in the "java" package hierarchy, an empty map will be returned.

Parameters:
clz - The class from which to extract descriptors.
Returns:
A non-null map of descriptors, keyed by property name.

loadBoundDescriptors

public static Map<String,PropertyDescriptor> loadBoundDescriptors(Object bean,
                                                                  boolean excludeReadOnly)
Loads bound properties, those with getters and setters, from the given bean. Any deprecated getter/setters and the "class" property will be excluded.

Parameters:
bean - The given bean from which to load descriptors.
excludeReadOnly - If true, properties without setters will be excluded.
Returns:
a map of bound property descriptors.

isDeprecated

public static boolean isDeprecated(Method read,
                                   Method write)
Returns true if either the given accessor or mutator has been annoted with Deprecated.

Parameters:
read - An accessor method of a property.
write - A mutator method of a property.
Returns:
true if either the given accessor or mutator has been annoted with Deprecated.

Please visit Base Apps, hosted on Sourceforge.net.

Copyright 2011, Blue Agate Software Entity (BASE)