Interface Sizer<T>

Type Parameters:
T - The type of object this sizer handles.
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Sizer<T>
Functional interface for computing the size of objects in test assertions.

Sizers are used by BeanConverter.size(Object) to determine the size of collection-like objects when validating test assertions. This provides a flexible way to compute sizes for custom types without needing to convert them to lists first.

Usage Example:

// Register a sizer for a custom collection type var converter = BasicBeanConverter.builder() .defaultSettings() .addSizer(MyCustomCollection.class, (coll, conv) -> coll.count()) .build(); // Use in assertions int size = converter.size(myCustomCollection);

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Computes the size of the given object.
  • Method Details

    • size

      int size(T o, BeanConverter bc)
      Computes the size of the given object.
      Parameters:
      o - The object to compute the size of. Will not be null.
      bc - The bean converter for accessing additional conversion utilities if needed.
      Returns:
      The size of the object.