Package org.hamcrest.beans
Class PropertyUtil
- java.lang.Object
-
- org.hamcrest.beans.PropertyUtil
-
public class PropertyUtil extends java.lang.ObjectUtility class for accessing properties on JavaBean objects. See http://java.sun.com/products/javabeans/docs/index.html for more information on JavaBeans.- Since:
- 1.1.0
- Author:
- Iain McGinniss, Steve Freeman
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Object[]NO_ARGUMENTS
-
Constructor Summary
Constructors Constructor Description PropertyUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.beans.PropertyDescriptorgetPropertyDescriptor(java.lang.String propertyName, java.lang.Object fromObj)Returns the description of the property with the provided name on the provided object's interface.static java.beans.PropertyDescriptor[]propertyDescriptorsFor(java.lang.Object fromObj, java.lang.Class<java.lang.Object> stopClass)Returns all the property descriptors for the class associated with the given object
-
-
-
Method Detail
-
getPropertyDescriptor
public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String propertyName, java.lang.Object fromObj) throws java.lang.IllegalArgumentExceptionReturns the description of the property with the provided name on the provided object's interface.- Parameters:
propertyName- the bean property name.fromObj- the object to check.- Returns:
- the descriptor of the property, or null if the property does not exist.
- Throws:
java.lang.IllegalArgumentException- if there's a introspection failure
-
propertyDescriptorsFor
public static java.beans.PropertyDescriptor[] propertyDescriptorsFor(java.lang.Object fromObj, java.lang.Class<java.lang.Object> stopClass) throws java.lang.IllegalArgumentExceptionReturns all the property descriptors for the class associated with the given object- Parameters:
fromObj- Use the class of this objectstopClass- Don't include any properties from this ancestor class upwards.- Returns:
- Property descriptors
- Throws:
java.lang.IllegalArgumentException- if there's a introspection failure
-
-