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

org.xs4j.util.NonNullValidator Maven / Gradle / Ivy

Go to download

An attempt to port parsing capabilities offered by Groovy XMLSlurper into the Java world. The following is not planned to be accurate projection, instead the most useful functions will be implemented.

The newest version!
package org.xs4j.util;

import java.util.Map;

/**
 * Created by mturski on 11/4/2016.
 */
public final class NonNullValidator {
    public static final  T requireNonNull(T obj) {
        if (obj == null)
            throw new NullPointerException();

        return obj;
    }

    public static final  T[] requireNonNull(T[] objs) {
        if (objs == null)
            throw new NullPointerException();

        for (T obj : objs)
            if (obj == null)
                throw new NullPointerException();

        return objs;
    }

    public static final  Map requireNonNull(Map map) {
        if (map == null)
            throw new NullPointerException();

        for (K key : map.keySet()) {
            if (key == null)
                throw new NullPointerException();

            if (map.get(key) == null)
                throw new NullPointerException();
        }

        return map;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy