Class FieldsOrPropertiesExtractor

java.lang.Object
org.assertj.core.groups.FieldsOrPropertiesExtractor

public class FieldsOrPropertiesExtractor extends Object
Understands how to retrieve fields or values from a collection/array of objects.

You just have to give the field/property name or a Function implementation, a collection/array of objects and it will extract the list of field/values from the given objects.

Author:
Joel Costigliola, Mateusz Haligowski
  • Constructor Details

    • FieldsOrPropertiesExtractor

      public FieldsOrPropertiesExtractor()
  • Method Details

    • extract

      public static <F, T> T[] extract(F[] objects, Function<? super F,T> extractor)
      Call extract(Iterable, Function) after converting objects to an iterable.

      Behavior is described in javadoc AbstractObjectArrayAssert.extracting(Function)

      Type Parameters:
      F - type of elements to extract a value from
      T - the extracted value type
      Parameters:
      objects - the elements to extract a value from
      extractor - the extractor function
      Returns:
      the extracted values
    • extract

      public static <F, T> List<T> extract(Iterable<? extends F> objects, Function<? super F,T> extractor)
      Type Parameters:
      F - type of elements to extract a value from
      T - the extracted value type
      Parameters:
      objects - the elements to extract a value from
      extractor - the extractor function
      Returns:
      the extracted values