Source Code : Validate: is true, not empty, no null element

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Validate: is true, not empty, no null element

import org.apache.commons.lang.Validate;

import java.util.List;
import java.util.ArrayList;

public class ValidateExampleV1 {

  public static void main(String args[]) {
    int i = 35;
    Validate.isTrue(i > 30); // Passes ok
    // Validate.isTrue(i > 40, "Invalid value: ", i); // throws custom Exception

    List data = new ArrayList();
    // Validate.notEmpty(data, "Collection cannot be empty"); // throws custom Exception

    data.add(null);
    Validate.noNullElements(data, "Collection contains null elements"); // throws custom Exception

  }
}
           
       

Thank with us