Package org.fest.assertions.internal
Class PropertySupport
- java.lang.Object
-
- org.fest.assertions.internal.PropertySupport
-
public class PropertySupport extends java.lang.ObjectUtility methods for properties access.- Author:
- Joel Costigliola, Alex Ruiz, Nicolas François, Florent Biville
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PropertySupportinstance()Returns the singleton instance of this class.<T> TpropertyValue(java.lang.String propertyName, java.lang.Class<T> clazz, java.lang.Object target)Return the value of property from a target object.<T> TpropertyValueOf(java.lang.String propertyName, java.lang.Class<T> clazz, java.lang.Object target)Returns the value of the given property name given target.static <T> TpropertyValueOf(java.lang.String propertyName, java.lang.Object target, java.lang.Class<T> clazz)Static variant ofpropertyValue(String, Class, Object)for syntactic sugar.<T> java.lang.Iterable<T>propertyValues(java.lang.String propertyName, java.lang.Class<T> clazz, java.lang.Iterable<?> target)Returns acontaining the values of the given property name, from the elements of the givenList.Iterable
-
-
-
Method Detail
-
instance
public static PropertySupport instance()
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
propertyValues
public <T> java.lang.Iterable<T> propertyValues(java.lang.String propertyName, java.lang.Class<T> clazz, java.lang.Iterable<?> target)Returns acontaining the values of the given property name, from the elements of the givenList. If the givenIterableIterableis empty ornull, this method will return an emptyList. This method supports nested properties (e.g. "address.street.number").- Parameters:
propertyName- the name of the property. It may be a nested property. It is left to the clients to validate fornullor empty.target- the givenIterable.- Returns:
- an
Iterablecontaining the values of the given property name, from the elements of the givenIterable. - Throws:
org.fest.util.IntrospectionError- if an element in the givenIterabledoes not have a property with a matching name.
-
propertyValueOf
public static <T> T propertyValueOf(java.lang.String propertyName, java.lang.Object target, java.lang.Class<T> clazz)Static variant ofpropertyValue(String, Class, Object)for syntactic sugar.- Parameters:
propertyName- the name of the property. It may be a nested property. It is left to the clients to validate fornullor empty.target- the given objectclazz- type of property- Returns:
- a the values of the given property name
- Throws:
org.fest.util.IntrospectionError- if the given target does not have a property with a matching name.
-
propertyValue
public <T> T propertyValue(java.lang.String propertyName, java.lang.Class<T> clazz, java.lang.Object target)Return the value of property from a target object.- Parameters:
propertyName- the name of the property. It may be a nested property. It is left to the clients to validate fornullor empty.target- the given objectclazz- type of property- Returns:
- a the values of the given property name
- Throws:
org.fest.util.IntrospectionError- if the given target does not have a property with a matching name.
-
propertyValueOf
public <T> T propertyValueOf(java.lang.String propertyName, java.lang.Class<T> clazz, java.lang.Object target)Returns the value of the given property name given target. If the given object isnull, this method will return null.
This method supports nested properties (e.g. "address.street.number").- Parameters:
propertyName- the name of the property. It may be a nested property. It is left to the clients to validate fornullor empty.clazz- the class of property.target- the given Object to extract property from.- Returns:
- the value of the given property name given target.
- Throws:
org.fest.util.IntrospectionError- if target object does not have a property with a matching name.
-
-