All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iohao.game.common.kit.adapter.HuObjectUtil Maven / Gradle / Ivy

There is a newer version: 21.20
Show newest version
package com.iohao.game.common.kit.adapter;

import java.util.Objects;
import java.util.function.Supplier;

/**
 * @author 渔民小镇
 * @date 2023-01-19
 */
class HuObjectUtil {

    public static  T defaultIfNull(T source, Supplier defaultValueSupplier) {
        if (isNull(source)) {
            return defaultValueSupplier.get();
        }
        return source;
    }

    public static boolean isNull(Object obj) {
        //noinspection ConstantConditions
        return Objects.isNull(obj);
    }

    public static  T defaultIfNull(final T object, final T defaultValue) {
        return isNull(object) ? defaultValue : object;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy