Top Description Fields Constructors Methods
org.assertj.core.groups

public Class Properties<T>

extends Object
Class Inheritance
Static Imports
java.util.Objects.requireNonNull, org.assertj.core.util.ArrayWrapperList.wrap, .Preconditions.checkArgument

Extracts the values of a specified property from the elements of a given Iterable or array.
Authors
Yvonne Wang, Mikhail Mazursky, Joel Costigliola, Florent Biville, Olivier Michallat

Field Summary

Modifier and TypeField and Description
pack-priv final String
pack-priv PropertySupport
pack-priv final Class<T>

Constructor Summary

AccessConstructor and Description
pack-priv
Properties(String propertyName, Class<T> propertyType)

Method Summary

Modifier and TypeMethod and Description
private static void
public static <
the type of value to extract.
T
>
Properties<T>

Returns:

the created Properties.
extractProperty
(String
the name of the property to be read from the elements of a Iterable. It may be a nested property (e.g. "address.street.number").
propertyName
,
Class<T>
the type of property to extract
propertyType
)

Creates a new Properties.

public static Properties<Object>

Returns:

the created Properties.
extractProperty
(String
the name of the property to be read from the elements of a Iterable. It may be a nested property (e.g. "address.street.number").
propertyName
)

Creates a new Properties with given propertyName and Object as property type.

public List<T>

Returns:

the values of the previously specified property extracted from the given Iterable.
from
(Iterable<?>
the given Iterable.
c
)

Extracts the values of the property (specified previously in extractProperty(String)) from the elements of the given Iterable.

public List<T>

Returns:

the values of the previously specified property extracted from the given array.
from
(Object[]
the given array.
array
)

Extracts the values of the property (specified previously in extractProperty(String)) from the elements of the given array.

public <
the type of value to extract.
U
>
Properties<U>

Returns:

a new Properties with the given type.
ofType
(Class<U>
the type of property to extract.
propertyType
)

Specifies the target type of an instance that was previously created with extractProperty(String).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

propertyNameback to summary
pack-priv final String propertyName
Annotations
@VisibleForTesting
propertySupportback to summary
pack-priv PropertySupport propertySupport
Annotations
@VisibleForTesting
propertyTypeback to summary
pack-priv final Class<T> propertyType

Constructor Detail

Propertiesback to summary
pack-priv Properties(String propertyName, Class<T> propertyType)
Annotations
@VisibleForTesting

Method Detail

checkIsNotNullOrEmptyback to summary
private static void checkIsNotNullOrEmpty(String propertyName)
extractPropertyback to summary
public static <T> Properties<T> extractProperty(String propertyName, Class<T> propertyType)

Creates a new Properties.

Parameters
<T>
the type of value to extract.
propertyName:String

the name of the property to be read from the elements of a Iterable. It may be a nested property (e.g. "address.street.number").

propertyType:Class<T>

the type of property to extract

Returns:Properties<T>

the created Properties.

Exceptions
NullPointerException:
if the given property name is null.
IllegalArgumentException:
if the given property name is empty.
extractPropertyback to summary
public static Properties<Object> extractProperty(String propertyName)

Creates a new Properties with given propertyName and Object as property type..

Parameters
propertyName:String

the name of the property to be read from the elements of a Iterable. It may be a nested property (e.g. "address.street.number").

Returns:Properties<Object>

the created Properties.

Exceptions
NullPointerException:
if the given property name is null.
IllegalArgumentException:
if the given property name is empty.
fromback to summary
public List<T> from(Iterable<?> c)

Extracts the values of the property (specified previously in extractProperty(String)) from the elements of the given Iterable.

Parameters
c:Iterable<?>

the given Iterable.

Returns:List<T>

the values of the previously specified property extracted from the given Iterable.

Exceptions
IntrospectionError:
if an element in the given Iterable does not have a property with a matching name.
fromback to summary
public List<T> from(Object[] array)

Extracts the values of the property (specified previously in extractProperty(String)) from the elements of the given array.

Parameters
array:Object[]

the given array.

Returns:List<T>

the values of the previously specified property extracted from the given array.

Exceptions
IntrospectionError:
if an element in the given array does not have a property with a matching name.
ofTypeback to summary
public <U> Properties<U> ofType(Class<U> propertyType)

Specifies the target type of an instance that was previously created with extractProperty(String).

This is so that you can write:

 extractProperty("name").ofType(String.class).from(fellowshipOfTheRing);
instead of:
 extractProperty("name", String.class).from(fellowshipOfTheRing);
Parameters
<U>
the type of value to extract.
propertyType:Class<U>

the type of property to extract.

Returns:Properties<U>

a new Properties with the given type.