Package org.hamcrest.beans
Class PropertyUtil
java.lang.Object
org.hamcrest.beans.PropertyUtil
Utility class with static methods for accessing properties on JavaBean objects.
See https://docs.oracle.com/javase/8/docs/technotes/guides/beans/index.html for
more information on JavaBeans.
- Since:
- 1.1.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Object[]
Empty object array, used for documenting that we are deliberately passing no arguments to a method. -
Method Summary
Modifier and TypeMethodDescriptionstatic PropertyDescriptor
getPropertyDescriptor
(String propertyName, Object fromObj) Returns the description of the property with the provided name on the provided object's interface.static PropertyDescriptor[]
propertyDescriptorsFor
(Object fromObj, Class<Object> stopClass) Returns all the property descriptors for the class associated with the given object
-
Field Details
-
NO_ARGUMENTS
Empty object array, used for documenting that we are deliberately passing no arguments to a method.
-
-
Method Details
-
getPropertyDescriptor
public static PropertyDescriptor getPropertyDescriptor(String propertyName, Object fromObj) throws IllegalArgumentException Returns 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:
IllegalArgumentException
- if there's a introspection failure
-
propertyDescriptorsFor
public static PropertyDescriptor[] propertyDescriptorsFor(Object fromObj, Class<Object> stopClass) throws IllegalArgumentException Returns 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:
IllegalArgumentException
- if there's a introspection failure
-