Java Collection Contain containsIgnoreCase(Collection collection, String value)

Here you can find the source of containsIgnoreCase(Collection collection, String value)

Description

Checks if the given collection of strings contains the provided string ignoring case.

License

LGPL

Parameter

Parameter Description
collection the collection to check if contains the given string
value the value to check for

Return

true, if found into the collection ignoring case.

Declaration

public static boolean containsIgnoreCase(Collection<String> collection, String value) 

Method Source Code

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

import java.util.Collection;

public class Main {
    /**/* w w  w.j  a va 2  s  .co m*/
     * Checks if the given collection of strings contains the provided string ignoring case.
     * <p>
     * <b>NOTE:</b> for optimal results if possible construct your collection only with lower/upper case strings. It's
     * going to be faster if the checks need to be performed often.
     *
     * @param collection
     *            the collection to check if contains the given string
     * @param value
     *            the value to check for
     * @return <code>true</code>, if found into the collection ignoring case.
     */
    public static boolean containsIgnoreCase(Collection<String> collection, String value) {
        if (value == null) {
            return false;
        }
        for (String string : collection) {
            if (string.equalsIgnoreCase(value)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. containsIdentity(Collection objects, Object object)
  2. containsIgnoreCase(Collection c, String s)
  3. containsIgnoreCase(Collection c, String s)
  4. containsIgnoreCase(Collection c, String str)
  5. containsIgnoreCase(Collection collection, String testString)
  6. containsIgnoreCase(Collection l, String s)
  7. containsIgnoreCase(String searchedWord, Collection words)
  8. containsIgnoreCase4Collections(Collection c, String s)
  9. containsInstance(Collection collection, Object element)