Reuse MapPropertySource for DynamicValuesPropertySource implementation
Closes gh-32110
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,4 +40,16 @@ public abstract class SupplierUtils {
|
||||
return (supplier != null ? supplier.get() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a given {@code Supplier}, getting its result or immediately
|
||||
* returning the given Object as-is if not a {@code Supplier}.
|
||||
* @param candidate the candidate to resolve (potentially a {@code Supplier})
|
||||
* @return a supplier's result or the given Object as-is
|
||||
* @since 6.1.4
|
||||
*/
|
||||
@Nullable
|
||||
public static Object resolve(@Nullable Object candidate) {
|
||||
return (candidate instanceof Supplier<?> supplier ? supplier.get() : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user