package com.gooddata;

import java.util.Collection;
import java.util.Iterator;

/**
 * Validation utils
 */
public abstract class Validate {

    public static <T> T notNull(T value, String aargument) {
        if (value == null) {
            throw new IllegalArgumentException(aargument + " can't be null");
        }
        return value;
    }

    public static <T extends CharSequence> T notEmpty(T value, String argument) {
        notNull(value, argument);
        if (value.toString().trim().length() == 0) {
            throw new IllegalArgumentException(argument + " can't be empty");
        }
        return value;
    }

    public static <T extends Collection> T noNullElements(T collection, String argument) {
        notNull(collection, argument);
        int i = 0;
        for (Iterator it = collection.iterator(); it.hasNext(); i++) {
            if (it.next() == null) {
                throw new IllegalArgumentException(argument + " contains null element at index: " + i);
            }
        }
        return collection;
    }

}

@@ -135,16 +135,299 @@
 date %7B%0A%0A
+    /**%0A     * Throws IllegalArgumentException if the value is null, otherwise returns the value.%0A     *%0A     * @param value        input value%0A     * @param argumentName the name of input argument%0A     * @param %3CT%3E          the type of the argument%0A     * @return the value%0A     */%0A
     publ
@@ -466,25 +466,24 @@
  String 
-a
 argument
 ) %7B%0A    
@@ -466,32 +466,36 @@
  String argument
+Name
 ) %7B%0A        if (
@@ -562,17 +562,16 @@
 ion(
-a
 argument
  + %22
@@ -558,32 +558,36 @@
 ception(argument
+Name
  + %22 can't be nu
@@ -623,32 +623,349 @@
 n value;%0A    %7D%0A%0A
+    /**%0A     * Throws IllegalArgumentException if the char sequence is empty, otherwise returns the char sequence.%0A     *%0A     * @param value        input char sequence%0A     * @param argumentName the name of input argument%0A     * @param %3CT%3E          the type of char sequence%0A     * @return the char sequence%0A     */%0A
     public stati
@@ -1018,32 +1018,36 @@
  String argument
+Name
 ) %7B%0A        notN
@@ -1057,32 +1057,36 @@
 (value, argument
+Name
 );%0A        if (v
@@ -1176,24 +1176,28 @@
 ion(argument
+Name
  + %22 can't b
@@ -1242,24 +1242,371 @@
 lue;%0A    %7D%0A%0A
+    /**%0A     *%0A     * Throws IllegalArgumentException if the collection contains null elements (or is null), otherwise returns%0A     * the collection.%0A     *%0A     * @param collection   input collection%0A     * @param argumentName the name of input argument%0A     * @param %3CT%3E          the type of the collection%0A     * @return the collection%0A     */%0A
     public s
@@ -1680,16 +1680,20 @@
 argument
+Name
 ) %7B%0A    
@@ -1724,16 +1724,20 @@
 argument
+Name
 );%0A     
@@ -1917,16 +1917,20 @@
 argument
+Name
  + %22 con

document Validate class