Java Collection Contain isNullOrContains(final Collection collection, final T item)

Here you can find the source of isNullOrContains(final Collection collection, final T item)

Description

is Null Or Contains

License

Artistic License

Declaration

public static <T> boolean isNullOrContains(final Collection<?> collection, final T item) 

Method Source Code

//package com.java2s;
/**//  w  w  w  .j  a  va  2s .  co  m
 * (c) 2009-2014 Peter Wullinger
 *
 * $Id$
 *
 * Use, modification and restribution of this file are covered by the
 * terms of the Artistic License 2.0.
 *
 * You should have received a copy of the license terms in a file named
 * "LICENSE" together with this software package.
 *
 * Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT
 * HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
 * A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE
 * EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO
 * COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT
 * OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 **/

import java.util.Collection;

public class Main {
    public static <T> boolean isNullOrContains(final Collection<?> collection, final T item) {
        return ((collection == null) || collection.contains(item));
    }
}

Related

  1. containsStringIgnoreCase(Collection strings, String toCheck)
  2. getContainmentRelation(Collection a, Collection b)
  3. intersect(Collection container, Collection contained)
  4. isAnyElementContains(String str, Collection col)
  5. isContained(Collection container, String strSearch)
  6. stringContainsOneOfStringsFromCollection(final String pattern, final Collection collection)