org.hamcrest.beans
Class PropertyUtil

java.lang.Object
  extended by org.hamcrest.beans.PropertyUtil

public class PropertyUtil
extends java.lang.Object

Utility 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
static java.lang.Object[] NO_ARGUMENTS
           
 
Constructor Summary
PropertyUtil()
           
 
Method Summary
static java.beans.PropertyDescriptor getPropertyDescriptor(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ARGUMENTS

public static final java.lang.Object[] NO_ARGUMENTS
Constructor Detail

PropertyUtil

public PropertyUtil()
Method Detail

getPropertyDescriptor

public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String propertyName,
                                                                  java.lang.Object fromObj)
                                                           throws java.lang.IllegalArgumentException
Returns the description of the property with the provided name on the provided object's interface.

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.IllegalArgumentException
Returns all the property descriptors for the class associated with the given object

Parameters:
fromObj - Use the class of this object
stopClass - Don't include any properties from this ancestor class upwards.
Returns:
Property descriptors
Throws:
java.lang.IllegalArgumentException - if there's a introspection failure