Package org.assertj.core.groups
Class Properties<T>
- java.lang.Object
-
- org.assertj.core.groups.Properties<T>
-
public class Properties<T> extends java.lang.ObjectExtracts the values of a specified property from the elements of a givenor array.Iterable
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.StringpropertyName(package private) PropertySupportpropertySupport(package private) java.lang.Class<T>propertyType
-
Constructor Summary
Constructors Constructor Description Properties(java.lang.String propertyName, java.lang.Class<T> propertyType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidcheckIsNotNullOrEmpty(java.lang.String propertyName)static Properties<java.lang.Object>extractProperty(java.lang.String propertyName)Creates a new.Propertieswith given propertyName and Object as property type.static <T> Properties<T>extractProperty(java.lang.String propertyName, java.lang.Class<T> propertyType)Creates a new.Propertiesjava.util.List<T>from(java.lang.Iterable<?> c)Extracts the values of the property (specified previously in) from the elements of the givenextractProperty(String).Iterablejava.util.List<T>from(java.lang.Object[] array)Extracts the values of the property (specified previously in) from the elements of the given array.extractProperty(String)<U> Properties<U>ofType(java.lang.Class<U> propertyType)Specifies the target type of an instance that was previously created withextractProperty(String).
-
-
-
Field Detail
-
propertyName
final java.lang.String propertyName
-
propertyType
final java.lang.Class<T> propertyType
-
propertySupport
PropertySupport propertySupport
-
-
Constructor Detail
-
Properties
Properties(java.lang.String propertyName, java.lang.Class<T> propertyType)
-
-
Method Detail
-
extractProperty
public static <T> Properties<T> extractProperty(java.lang.String propertyName, java.lang.Class<T> propertyType)
Creates a new.Properties- Type Parameters:
T- the type of value to extract.- Parameters:
propertyName- the name of the property to be read from the elements of aIterable. It may be a nested property (e.g. "address.street.number").propertyType- the type of property to extract- Returns:
- the created
Properties. - Throws:
java.lang.NullPointerException- if the given property name isnull.java.lang.IllegalArgumentException- if the given property name is empty.
-
extractProperty
public static Properties<java.lang.Object> extractProperty(java.lang.String propertyName)
Creates a new.Propertieswith given propertyName and Object as property type.- Parameters:
propertyName- the name of the property to be read from the elements of aIterable. It may be a nested property (e.g. "address.street.number").- Returns:
- the created
Properties. - Throws:
java.lang.NullPointerException- if the given property name isnull.java.lang.IllegalArgumentException- if the given property name is empty.
-
checkIsNotNullOrEmpty
private static void checkIsNotNullOrEmpty(java.lang.String propertyName)
-
ofType
public <U> Properties<U> ofType(java.lang.Class<U> propertyType)
Specifies the target type of an instance that was previously created withextractProperty(String).This is so that you can write:
instead of:extractProperty("name").ofType(String.class).from(fellowshipOfTheRing);extractProperty("name", String.class).from(fellowshipOfTheRing);- Type Parameters:
U- the type of value to extract.- Parameters:
propertyType- the type of property to extract.- Returns:
- a new
Propertieswith the given type.
-
from
public java.util.List<T> from(java.lang.Iterable<?> c)
Extracts the values of the property (specified previously in) from the elements of the givenextractProperty(String).Iterable- Parameters:
c- the givenIterable.- Returns:
- the values of the previously specified property extracted from the given
Iterable. - Throws:
IntrospectionError- if an element in the givenIterabledoes not have a property with a matching name.
-
from
public java.util.List<T> from(java.lang.Object[] array)
Extracts the values of the property (specified previously in) from the elements of the given array.extractProperty(String)- Parameters:
array- the given array.- Returns:
- the values of the previously specified property extracted from the given array.
- Throws:
IntrospectionError- if an element in the given array does not have a property with a matching name.
-
-