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 Function<Object,Object>
byName(String fieldOrProperty)
Provides extractor for extracting single field or property from any object using reflectionstatic Function<Object,Tuple>
byName(String... fieldsOrProperties)
Provides extractor for extracting multiple fields or properties from any object using reflectionstatic String
extractedDescriptionOf(Object... items)
static String
extractedDescriptionOf(String... itemsDescription)
static String
extractedDescriptionOfMethod(String method)
static Function<Object,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 Function<Object,Object> byName(String fieldOrProperty)
Provides extractor for extracting single field or property from any object using reflection- Parameters:
fieldOrProperty
- the name of the field/property to extract- Returns:
- the built
Function
-
byName
public static Function<Object,Tuple> byName(String... fieldsOrProperties)
Provides extractor for extracting multiple fields or properties from any object using reflection- Parameters:
fieldsOrProperties
- the name of the fields/properties to extract- Returns:
- the built
Function
-
resultOf
public static Function<Object,Object> resultOf(String methodName)
Provides extractor for extracting values by method name from any object using reflection- Parameters:
methodName
- the name of the method to execute- Returns:
- the built
Function
-
-