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

io.github.hylexus.jt.utils.Assertions Maven / Gradle / Ivy

There is a newer version: 2.3.0-rc.1
Show newest version
package io.github.hylexus.jt.utils;

import java.util.function.Predicate;

/**
 * @author hylexus
 */
public abstract class Assertions {
    private Assertions() {
    }

    public static void assertThat(boolean condition, String msg) {
        if (!condition) {
            throw new IllegalArgumentException(msg);
        }
    }

    public static  T assertThat(T t, Predicate predicate, String msg) {
        if (!predicate.test(t)) {
            throw new IllegalArgumentException(msg);
        }
        return t;
    }

    public static  T requireNonNull(T obj, String msg) {
        if (obj == null) {
            throw new NullPointerException(msg);
        }
        return obj;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy