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

cn.kduck.core.utils.ObjectUtils Maven / Gradle / Ivy

Go to download

The core of the K-Duck development framework encompasses all the featured components of the framework.

There is a newer version: 2.0.0
Show newest version
package cn.kduck.core.utils;

import java.util.function.Function;

public final class ObjectUtils {

    private ObjectUtils(){}

    public static  boolean isNull(T obj, Function objectField){
        if(obj == null) return true;
        return objectField.apply(obj) == null;
    }

    public static  R valueOrNull(T obj, Function objectField){
        if(obj == null) return null;
        return objectField.apply(obj);
    }

    public static  R valueOrDefault(T obj, Function objectField,R defaultValue){
        R r = valueOrNull(obj, objectField);
        return r == null ? defaultValue : r;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy