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

com.hibegin.common.util.ObjectUtil Maven / Gradle / Ivy

Go to download

Simple, flexible, less dependent, more extended. Less memory footprint, can quickly build Web project. Can quickly run embedded, Android devices

There is a newer version: 0.3.162
Show newest version
package com.hibegin.common.util;

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

public class ObjectUtil {

    public static  T requireNonNullElse(T obj, T defaultObj) {
        return (T)(obj != null ? obj : Objects.requireNonNull(defaultObj, "defaultObj"));
    }

    public static  T requireNonNullElseGet(T obj, Supplier supplier) {
        return (T)(obj != null ? obj : Objects.requireNonNull(((Supplier)Objects.requireNonNull(supplier, "supplier")).get(), "supplier.get()"));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy