Java Collection Contain containsIgnoreCase(Collection collection, String testString)

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

Description

Utility method which does a case-insensitive check on the given Collection of Strings for the passed testString, returning true if the Collection contains the passed string

License

Open Source License

Parameter

Parameter Description
collection collection to loop over
testString String to look for in the <code>collection</code>

Return

true/false whether the given testString is found, ignoring case

Declaration

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

Method Source Code

//package com.java2s;
/**/*from  w ww .jav  a2  s . co m*/
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */

import java.util.Collection;

public class Main {
    /**
     * Utility method which does a case-insensitive check on the given Collection of Strings
     * for the passed testString, returning true if the Collection contains the passed string
     * @param collection collection to loop over
     * @param testString String to look for in the <code>collection</code>
     * @return true/false whether the given testString is found, ignoring case
     */
    public static boolean containsIgnoreCase(Collection<String> collection,
            String testString) {
        if (collection == null) {
            return false;
        }
        for (String s : collection) {
            if (s.equalsIgnoreCase(testString)) {
                return true;
            }
        }
        return false;
    }
}

Related

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