Interface Listifier<T>

Type Parameters:
T - The type of collection-like object this listifier handles
All Superinterfaces:
BiFunction<BeanConverter,T,List<Object>>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Functional interface for converting collection-like objects to standardized List<Object> format.

Listifiers enable the Bean-Centric Testing framework to treat diverse collection-like objects uniformly during property access and iteration. They convert various iterable structures into a common List format for consistent processing.

Common Use Cases:
  • Arrays: Convert primitive and object arrays to lists
  • Streams: Materialize Stream objects to lists
  • Custom collections: Extract elements from domain-specific collections
  • Map entries: Convert Maps to lists of entry objects
  • Iterables: Handle any Iterable implementation
Usage Examples:

// Custom collection handling Listifier<ResultSet> resultSetListifier = (conv, rs) -> { var results = new ArrayList<>(); while (rs.next()) { results.add(rs.getRowData()); // Custom row extraction } return results; }; // Stream processing with side effects Listifier<Stream> streamListifier = (conv, stream) -> stream.peek(logProcessor::log).collect(toList()); // Custom data structure Listifier<Tree> treeListifier = (conv, tree) -> tree.traversePreOrder().collect(toList());

Registration:

var converter = BasicBeanConverter.builder() .defaultSettings() .addListifier(ResultSet.class, resultSetListifier) .addListifier(Stream.class, streamListifier) .addListifier(Tree.class, treeListifier) .build();

Best Practices:
  • Preserve order when the original collection has meaningful ordering
  • Handle empty cases gracefully (return empty list, not null)
  • Consider performance for large collections (avoid full materialization when possible)
  • Use converter parameter for swapping/transforming individual elements
See Also: