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

cn.k7g.alloy.utils.Any Maven / Gradle / Ivy

package cn.k7g.alloy.utils;

import java.util.function.Supplier;

public class Any {

    public static  T or(T origin, T defaultVal) {
        return origin != null ? origin : defaultVal;
    }

    public static  T or(T origin, Supplier exceptionSupplier) throws X {
        if (origin != null) {
            return origin;
        }
        throw exceptionSupplier.get();
    }

    public static  T orGet(T origin, Supplier other) {
        return origin != null ? origin : other.get();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy