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

com.bol.ipresource.util.Validate Maven / Gradle / Ivy

Go to download

High performance, low memory IP library (originally developed for RIPE NCC Whois server)

There is a newer version: 1.4.7
Show newest version
package com.bol.ipresource.util;

import java.util.Collection;

public class Validate {
    public static void notNull(Object object) {
        notNull(object, "The validated object is null");
    }

    public static void notNull(Object object, String message) {
        if (object == null) throw new IllegalArgumentException(message);
    }

    public static void notEmpty(Collection collection, String message) {
        if (collection == null || collection.size() == 0) throw new IllegalArgumentException(message);
    }

    public static void notEmpty(Collection collection) {
        notEmpty(collection, "The validated collection is empty");
    }

    public static void notEmpty(String string, String message) {
        if (string == null || string.length() == 0) throw new IllegalArgumentException(message);
    }

    public static void notEmpty(String string) {
        notEmpty(string, "The validated string is empty");
    }

    public static void isTrue(boolean expression, String message, Object value) {
        if (!expression) throw new IllegalArgumentException(message + value);
    }

    public static void isTrue(boolean expression, String message) {
        if (!expression) throw new IllegalArgumentException(message);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy