Similar to: eclipse-ee4j/mojarra#4568
we already have a eval() with a lambda to provide the default value. However, this defaultValueSupplier does NOT store it as default in the state/stateHelper.
computeIfAbsent however will store the defaultValue in the state.
See PF code:
/**
* <p class="changed_added_5_0">
* Performs the same logic as {@link #get(java.io.Serializable)} } but if no value is found, this will return the
* the evaluated value from the given <code>defaultValueSupplier</code>
* </p>
*
* @param key the key for which the value should be returned.
* @param defaultValueSupplier the dynamic suppler which resolves the defaultValue if no value is found in the call to <code>eval()</code>.
* @return the evaluated value.
* @since 5.0
*/
public static <T> T computeIfAbsent(Serializable key, Supplier<T> defaultValueSupplier) {
T value = (T) get(key);
if (value == null) {
value = defaultValueSupplier.get();
stateHelper.put(key, value);
}
return value;
}
Similar to: eclipse-ee4j/mojarra#4568
we already have a eval() with a lambda to provide the default value. However, this defaultValueSupplier does NOT store it as default in the state/stateHelper.
computeIfAbsent however will store the defaultValue in the state.
See PF code: