Skip to content

Add Stream counterparts to ReflectionSupport utility methods returning List #2779

Closed
@kriegfrj

Description

@kriegfrj

Methods like ReflectionSupport.findField currently return a List<Field>.

Under-the-hood, the utils typically use streams and then copy all the elements into a list to return.

Very often, users of findfield() only need to iterate once through the returned list of fields (in some of my implementations, I've called stream() or forEach() on the result). Storing the stream of fields in an intermediate List is unnecessary buffering overhead in those cases.

Deliverables

  • A set of methods with a signature like Stream<Field> findFieldsAsStream().
  • Refactor the existing List<Field> findFields() to delegate to its equivalent streaming method and call toList() on the stream.
  • Refactor existing usage in the JUnit 5 codebase where the stream interface would be more appropriate and efficient.

Thoughts?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions