Java Collection Contain containsStringIgnoreCase(Collection strings, String toCheck)

Here you can find the source of containsStringIgnoreCase(Collection strings, String toCheck)

Description

Check if the collection has toCheck str in it, ignoring case sensitivity

License

Open Source License

Parameter

Parameter Description
strings collection of strings
toCheck the one to be checked

Declaration

public static boolean containsStringIgnoreCase(Collection strings, String toCheck) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {
    /**// w w w. ja  v a  2 s  .  c o  m
     * Check if the collection has toCheck str in it, ignoring case sensitivity
     *
     * @param strings collection of strings
     * @param toCheck the one to be checked
     * @return
     */
    public static boolean containsStringIgnoreCase(Collection strings, String toCheck) {
        if (toCheck == null) {
            return false;
        }

        //TODO: Find better way of doing this comparison.
        for (Iterator it = strings.iterator(); it.hasNext();) {
            if (toCheck.equalsIgnoreCase((String) it.next())) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. containsSome(Collection source, Collection target)
  2. containsSome(final Collection c1, final Collection c2)
  3. containsSome(HashSet s1, Collection other)
  4. containsString(Collection coll, String str)
  5. containsString(String stringToCheck, Collection collection)
  6. getContainmentRelation(Collection a, Collection b)
  7. intersect(Collection container, Collection contained)
  8. isAnyElementContains(String str, Collection col)
  9. isContained(Collection container, String strSearch)