Java Collection Contain containsNoNull(final Collection c, final String s)

Here you can find the source of containsNoNull(final Collection c, final String s)

Description

Checks that the collection does not contain a null value (throws an IllegalArgumentException if it does).

License

Apache License

Parameter

Parameter Description
c collection
s the text message that would be pass to the exception thrown when c contains a null.

Exception

Parameter Description
IllegalArgumentException if a o == null

Declaration

public static <T> void containsNoNull(final Collection<?> c, final String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**//ww  w.j  a v  a 2s .  co m
     * Checks that the collection does not contain a {@code null} value (throws an {@link IllegalArgumentException} if it does).
     * The implementation calls {@code c.contains(null)} to determine the presence of null.
     * @param c collection
     * @param s the text message that would be pass to the exception thrown when c contains a null.
     * @throws IllegalArgumentException if a {@code o == null}
     */
    public static <T> void containsNoNull(final Collection<?> c, final String s) {
        if (c.contains(null)) {
            throw new IllegalArgumentException(s);
        }
    }
}

Related

  1. containsInstance(Collection collection, Object element)
  2. containsInstanceOf(Collection collection, Class c)
  3. containsKey(Collection keys, String key)
  4. containsNo(Collection baseList, Collection valueList)
  5. containsNone(Collection container, Collection other)
  6. containsNoNulls(Collection container)
  7. containsNull(Collection collection)
  8. containsNull(Collection args)
  9. containsNull(final Collection c)

  10. HOME | Copyright © www.java2s.com 2016