dev.openfeature.sdk.internal.ObjectUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk Show documentation
Show all versions of sdk Show documentation
This is the Java implementation of OpenFeature, a vendor-agnostic abstraction library for evaluating feature flags.
The newest version!
package dev.openfeature.sdk.internal;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import lombok.experimental.UtilityClass;
@SuppressWarnings("checkstyle:MissingJavadocType")
@UtilityClass
public class ObjectUtils {
/**
* If the source param is null, return the default value.
* @param source maybe null object
* @param defaultValue thing to use if source is null
* @param list type
* @return resulting object
*/
public static List defaultIfNull(List source, Supplier> defaultValue) {
if (source == null) {
return defaultValue.get();
}
return source;
}
/**
* If the source param is null, return the default value.
* @param source maybe null object
* @param defaultValue thing to use if source is null
* @param map key type
* @param map value type
* @return resulting map
*/
public static Map defaultIfNull(Map source, Supplier