Skip to content

Lambda-based mapping of an ObjectProvider's object when available or unique [SPR-17170] #21706

Closed as not planned
@spring-projects-issues

Description

@spring-projects-issues

Yanming Zhou opened SPR-17170 and commented

ObjectProvider should accept Function as argument like Consumer #20550

	public default <R> Optional<R> ifAvailable(Function<T, R> dependencyFunction) throws BeansException {
		T dependency = getIfAvailable();
		if (dependency != null) {
			return Optional.ofNullable(dependencyFunction.apply(dependency));
		}
		return Optional.empty();
	}

	public default <R> Optional<R> ifUnique(Function<T, R> dependencyFunction) throws BeansException {
		T dependency = getIfUnique();
		if (dependency != null) {
			return Optional.ofNullable(dependencyFunction.apply(dependency));
		}
		return Optional.empty();
	}

No further details from SPR-17170

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions