Package org.assertj.core.extractor
Class Extractors
- java.lang.Object
-
- org.assertj.core.extractor.Extractors
-
public class Extractors extends java.lang.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");
-
-
Constructor Summary
Constructors Constructor Description Extractors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <F> java.util.function.Function<F,java.lang.Object>
byName(java.lang.String fieldOrProperty)
Provides extractor for extracting single field or property from any object using reflectionstatic <F> java.util.function.Function<F,Tuple>
byName(java.lang.String... fieldsOrProperties)
Provides extractor for extracting multiple fields or properties from any object using reflectionstatic java.lang.String
extractedDescriptionOf(java.lang.Object... items)
static java.lang.String
extractedDescriptionOf(java.lang.String... itemsDescription)
static java.lang.String
extractedDescriptionOfMethod(java.lang.String method)
static <F> java.util.function.Function<F,java.lang.Object>
resultOf(java.lang.String methodName)
Provides extractor for extracting values by method name from any object using reflectionstatic java.util.function.Function<java.lang.Object,java.lang.String>
toStringMethod()
Provides extractor for extractingObject.toString()
from any object
-
-
-
Method Detail
-
toStringMethod
public static java.util.function.Function<java.lang.Object,java.lang.String> toStringMethod()
Provides extractor for extractingObject.toString()
from any object- Returns:
- the built
Function
-
byName
public static <F> java.util.function.Function<F,java.lang.Object> byName(java.lang.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> java.util.function.Function<F,Tuple> byName(java.lang.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> java.util.function.Function<F,java.lang.Object> resultOf(java.lang.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
-
extractedDescriptionOf
public static java.lang.String extractedDescriptionOf(java.lang.String... itemsDescription)
-
extractedDescriptionOf
public static java.lang.String extractedDescriptionOf(java.lang.Object... items)
-
extractedDescriptionOfMethod
public static java.lang.String extractedDescriptionOfMethod(java.lang.String method)
-
-