Package org.assertj.core.extractor
Class Extractors
- java.lang.Object
-
- org.assertj.core.extractor.Extractors
-
public class Extractors extends Object
Extractors factory, providing convenient methods of creating common extractors.For example:
assertThat(objectsList).extracting(toStringMethod()).contains("toString 1", "toString 2"); assertThat(objectsList).extracting(byName("field")).contains("someResult1", "someResult2");- Author:
- Mateusz Haligowski
-
-
Constructor Summary
Constructors Constructor Description Extractors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <F> Function<F,Object>byName(String fieldOrProperty)Provides extractor for extracting single field or property from any object using reflectionstatic <F> Function<F,Tuple>byName(String... fieldsOrProperties)Provides extractor for extracting multiple fields or properties from any object using reflectionstatic StringextractedDescriptionOf(Object... items)static StringextractedDescriptionOf(String... itemsDescription)static StringextractedDescriptionOfMethod(String method)static <F> Function<F,Object>resultOf(String methodName)Provides extractor for extracting values by method name from any object using reflectionstatic Function<Object,String>toStringMethod()Provides extractor for extractingObject.toString()from any object
-
-
-
Method Detail
-
toStringMethod
public static Function<Object,String> toStringMethod()
Provides extractor for extractingObject.toString()from any object- Returns:
- the built
Function
-
byName
public static <F> Function<F,Object> byName(String fieldOrProperty)
Provides extractor for extracting single field or property from any object using reflection- Type Parameters:
F- type to extract property from- Parameters:
fieldOrProperty- the name of the field/property to extract- Returns:
- the built
Function
-
byName
public static <F> Function<F,Tuple> byName(String... fieldsOrProperties)
Provides extractor for extracting multiple fields or properties from any object using reflection- Type Parameters:
F- type to extract property from- Parameters:
fieldsOrProperties- the name of the fields/properties to extract- Returns:
- the built
Function
-
resultOf
public static <F> Function<F,Object> resultOf(String methodName)
Provides extractor for extracting values by method name from any object using reflection- Type Parameters:
F- type to extract property from- Parameters:
methodName- the name of the method to execute- Returns:
- the built
Function
-
-