Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let custom ObjectProvider implementations declare a single method only #33070

Closed
jhoeller opened this issue Jun 19, 2024 · 0 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@jhoeller
Copy link
Contributor

Historically, ObjectProvider comes with several default methods already but still requires concrete implementations to declare four methods. For unit testing purposes, it would be great to just declare the concrete method that a caller actually needs (such as getObject() or getIfAvailable()), or to provide a stream() implementation with all other ObjectProvider methods reacting to it, e.g.

		new ObjectProvider<MyBean>() {
			@Override
			public Stream<MyBean> stream() {
				return Stream.of(bean1, bean2);
			}
		};

or

		new ObjectProvider<MyBean>() {
			@Override
			public Stream<MyBean> stream() {
				return Stream.empty();
			}
		};

As of 6.2, a complete set of default methods in ObjectProvider itself enables all kinds of such custom usage.

@jhoeller jhoeller self-assigned this Jun 19, 2024
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Jun 19, 2024
@jhoeller jhoeller added this to the 6.2.0-M5 milestone Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant