Validates if the given String is not null and has a value grater than 0. - Android java.lang

Android examples for java.lang:String Null or Empty

Description

Validates if the given String is not null and has a value grater than 0.

Demo Code


import android.util.Log;

public class Main{
    /**/* w w w . j a v  a2  s  . c o  m*/
     * Validates if the given String is not null and has a value grater than 0. If it is not, throws
     * an {@link IllegalArgumentException} with the given message.
     * 
     * @param value
     *            The value to be checked.
     * @param message
     *            The message of the exception.
     */
    public static void notEmpty(String value, String message) {
        if (StringUtils.isEmpty(value)) {
            throw new IllegalArgumentException(message);
        }
    }
    /**
     * Validates if the given String is not null and has a value grater than 0. If it is not, throws
     * an {@link IllegalArgumentException}.
     * 
     * @param value
     *            The value to be checked.
     */
    public static void notEmpty(String value) {
        notEmpty(value, "Null or empty String!");
    }
}

Related Tutorials