Package org.fest.assertions
Class PropertySupport
java.lang.Object
org.fest.assertions.PropertySupport
Understands utility methods related to properties.
- Since:
- 1.3
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringfirstPropertyIfNested(String propertyName) Returns the first property from the given property name only if the given property name belongs to a nested property.(package private) static booleanisNestedProperty(String propertyName) Returnstrueif property is nested,falseotherwise.private static ObjectpropertyValue(String propertyName, Object target) propertyValues(String propertyName, Collection<?> target) Returns a list containing the values of the given property name, from the elements of the given collection.(package private) static StringremoveFirstPropertyIfNested(String propertyName) Removes the first property from the given property name only if the given property name belongs to a nested property.simplePropertyValues(String propertyName, Collection<?> target)
-
Field Details
-
SEPARATOR
- See Also:
-
-
Constructor Details
-
PropertySupport
private PropertySupport()
-
-
Method Details
-
propertyValues
Returns a list containing the values of the given property name, from the elements of the given collection. If the given collection is empty ornull, this method will return an empty collection.For example, given the nested property "address.street.number", this method will:
- extract a collection of "address" from the given collection (remaining property is 'street.number')
- extract a collection of "street" from the "address" collection (remaining property is 'number')
- extract a collection of "number" from the "street" collection
- Parameters:
propertyName- the name of the property. It may be a nested property.target- the given collection.- Returns:
- a list containing the values of the given property name, from the elements of the given collection.
- Throws:
NullPointerException- if given property name isnull.org.fest.util.IntrospectionError- if an element in the given collection does not have a matching property.
-
isNestedProperty
Returnstrueif property is nested,falseotherwise.Examples:
isNestedProperty("address.street"); // true isNestedProperty("address.street.name"); // true isNestedProperty("person"); // false isNestedProperty(".name"); // false isNestedProperty("person."); // false isNestedProperty("person.name."); // false isNestedProperty(".person.name"); // false isNestedProperty("."); // false isNestedProperty(""); // false- Parameters:
propertyName- the given property name.- Returns:
trueif property is nested,falseotherwise.- Throws:
NullPointerException- if given property name isnull.
-
removeFirstPropertyIfNested
Removes the first property from the given property name only if the given property name belongs to a nested property. For example, given the nested property "address.street.name", this method will return "street.name". This method returns an emptyStringif the given property name does not belong to a nested property.- Parameters:
propertyName- the given property name.- Returns:
- the given property name without its first property, if the property name belongs to a nested property;
otherwise, it will return an empty
String. - Throws:
NullPointerException- if given property name isnull.
-
firstPropertyIfNested
Returns the first property from the given property name only if the given property name belongs to a nested property. For example, given the nested property "address.street.name", this method will return "address". This method returns the given property name unchanged if it does not belong to a nested property.- Parameters:
propertyName- the given property name.- Returns:
- the first property from the given property name, if the property name belongs to a nested property; otherwise, it will return the given property name unchanged.
- Throws:
NullPointerException- if given property name isnull.
-
simplePropertyValues
-
propertyValue
-